当前位置: 首页 > news >正文

选择邯郸网站制作外链发布论坛

选择邯郸网站制作,外链发布论坛,做网站对服务器要求,娃哈哈软文推广背景 MVVM 是一种软件架构模式#xff0c;用于创建用户界面。它将用户界面#xff08;View#xff09;、业务逻辑#xff08;ViewModel#xff09;和数据模型#xff08;Model#xff09;分离开来#xff0c;以提高代码的可维护性和可测试性。 MainWindow 类是 View用于创建用户界面。它将用户界面View、业务逻辑ViewModel和数据模型Model分离开来以提高代码的可维护性和可测试性。 MainWindow 类是 View视图负责用户界面的呈现和交互它是用户直接看到和操作的部分。 LoginVM 类是 ViewModel视图模型它充当了 View 和 Model 之间的中介处理了视图与数据模型之间的交互逻辑以及用户操作的响应逻辑。 LoginModel 类是 Model模型它包含了应用程序的数据和业务逻辑用于存储和处理用户的身份验证信息。 展示 代码 LoginModel.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace WpfApp2 {public class LoginModel{private string _UserName;public string UserName{get { return _UserName; }set{_UserName value;}}private string _Password;public string Password{get { return _Password; }set{_Password value;}}} } LoginVM.cs using Sys tem; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input;namespace WpfApp2 {public class LoginVM : INotifyPropertyChanged{private MainWindow _main;public LoginVM(MainWindow main){_main main;}public event PropertyChangedEventHandler PropertyChanged;private void RaisePropetyChanged(string propertyName){PropertyChangedEventHandler handler PropertyChanged;if (handler ! null){handler(this, new PropertyChangedEventArgs(propertyName));}}private LoginModel _LoginM new LoginModel();public string UserName{get { return _LoginM.UserName; }set{_LoginM.UserName value;RaisePropetyChanged(UserName);}}public string Password{get { return _LoginM.Password; }set{_LoginM.Password value;RaisePropetyChanged(Password);}}/// summary/// 登录方法/// /summaryvoid Loginfunc(){if (UserName wpf Password 666){MessageBox.Show(OK);Index index new Index();index.Show();//想办法拿到mainwindow_main.Hide();}else{MessageBox.Show(输入的用户名或密码不正确);UserName ;Password ;}}bool CanLoginExecute(){return true;}public ICommand LoginAction{get{return new RelayCommand(Loginfunc,CanLoginExecute);}}} } MainWindow.xaml Window x:ClassWpfApp2.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:WpfApp2mc:IgnorabledTitleMainWindow Height450 Width800GridGrid.RowDefinitionsRowDefinition Heightauto/RowDefinitionRowDefinition Heightauto/RowDefinitionRowDefinition Height1*/RowDefinitionRowDefinition Height9*/RowDefinition/Grid.RowDefinitionsTextBlock Grid.Row0 Grid.Column0 Text上海市-市图书馆 FontSize18 HorizontalAlignmentCenter/TextBlockStackPanel Grid.Row1 Grid.Column0 Background#0078d4TextBlock Text登录 FontSize22 HorizontalAlignmentCenter ForegroundWheat Margin5/TextBlock /StackPanelGrid Grid.Row3 ShowGridLinesFalse HorizontalAlignmentCenterGrid.RowDefinitionsRowDefinition Height30/RowDefinitionRowDefinition Height30/RowDefinitionRowDefinition Height30/RowDefinitionRowDefinition Height30/RowDefinition/Grid.RowDefinitionsGrid.ColumnDefinitions ColumnDefinition Widthauto/ColumnDefinitionColumnDefinition Width200/ColumnDefinition/Grid.ColumnDefinitionsTextBlock Text用户名 Grid.Row0 Grid.Column0 VerticalAlignmentCenter/TextBlockTextBox Text{Binding UserName} Grid.Row0 Grid.Column1 Margin2 /TextBoxTextBlock Text密码 Grid.Row1 Grid.Column0 VerticalAlignmentCenter/TextBlockTextBox Text{Binding Password} Grid.Row1 Grid.Column1 Margin2/TextBoxCheckBox Grid.ColumnSpan2 Content记住密码 Grid.Row2/CheckBoxlocal:CustomButton ButtonCornerRadius5 BackgroundHoverRed BackgroundPressedGreen Foreground#FFFFFF Background#3C7FF8 Grid.Row3 Grid.Column0 Grid.ColumnSpan2 Command{Binding LoginAction} Height30 VerticalAlignmentTop登录/local:CustomButton/Grid/Grid /Window MainWindow.xaml.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;namespace WpfApp2 {/// summary/// MainWindow.xaml 的交互逻辑/// /summarypublic partial class MainWindow : Window{LoginVM loginVM;public MainWindow(){InitializeComponent();loginVM new LoginVM(this);this.DataContext loginVM;}} } RelayCommand.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input;namespace WpfApp2 {public class RelayCommand : ICommand{/// summary/// 命令是否能够执行/// /summaryreadonly Funcbool _canExecute;/// summary/// 命令需要执行的方法/// /summaryreadonly Action _exexute;public RelayCommand(Action exexute,Funcbool canExecute){_canExecute canExecute;_exexute exexute;}public bool CanExecute(object parameter){if (_canExecute null){return true;}return _canExecute();}public void Execute(object parameter){_exexute();}public event EventHandler CanExecuteChanged{add {if (_canExecute ! null){CommandManager.RequerySuggested value;}}remove{if (_canExecute ! null){CommandManager.RequerySuggested - value;}}}} } 自定义按钮CustomButton App.xaml.cs Application x:ClassWpfApp2.Appxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:localclr-namespace:WpfApp2StartupUriMainWindow.xamlApplication.ResourcesResourceDictionaryResourceDictionary.MergedDictionariesResourceDictionary SourceCustomButtonStyles.xaml/ResourceDictionary/ResourceDictionary.MergedDictionaries/ResourceDictionary/Application.Resources /Application CustomButton.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media;namespace WpfApp2 {public class CustomButton:Button{//依赖属性public CornerRadius ButtonCornerRadius{get { return (CornerRadius)GetValue(ButtonCornerRadiusProperty); }set { SetValue(ButtonCornerRadiusProperty, value); }}// Using a DependencyProperty as the backing store for ButtonCornerRadius. This enables animation, styling, binding, etc...public static readonly DependencyProperty ButtonCornerRadiusProperty DependencyProperty.Register(ButtonCornerRadius, typeof(CornerRadius), typeof(CustomButton));public Brush BackgroundHover{get { return (Brush)GetValue(BackgroundHoverProperty); }set { SetValue(BackgroundHoverProperty, value); }}// Using a DependencyProperty as the backing store for BackgroundHover. This enables animation, styling, binding, etc...public static readonly DependencyProperty BackgroundHoverProperty DependencyProperty.Register(BackgroundHover, typeof(Brush), typeof(CustomButton));public Brush BackgroundPressed{get { return (Brush)GetValue(BackgroundPressedProperty); }set { SetValue(BackgroundPressedProperty, value); }}// Using a DependencyProperty as the backing store for BackgroundPressed. This enables animation, styling, binding, etc...public static readonly DependencyProperty BackgroundPressedProperty DependencyProperty.Register(BackgroundPressed, typeof(Brush), typeof(CustomButton));} } 数据字典 CustombuttonStyles.xaml ResourceDictionary xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:bbclr-namespace:WpfApp2Style TargetType{x:Type bb:CustomButton}Setter PropertyTemplateSetter.ValueControlTemplate TargetType{x:Type bb:CustomButton}Border x:NamebuttonBorder Background{TemplateBinding Background} CornerRadius{TemplateBinding ButtonCornerRadius}TextBlock Text{TemplateBinding Content} HorizontalAlignment{TemplateBinding HorizontalContentAlignment} VerticalAlignment{TemplateBinding VerticalContentAlignment}/TextBlock/Border!--触发器--ControlTemplate.TriggersTrigger PropertyIsMouseOver ValueTrueSetter TargetNamebuttonBorder PropertyBackground Value{Binding BackgroundHover,RelativeSource{RelativeSource TemplatedParent}}/Setter/TriggerTrigger PropertyIsPressed ValueTrueSetter TargetNamebuttonBorder PropertyBackground Value{Binding BackgroundPressed,RelativeSource{RelativeSource TemplatedParent}}/Setter/Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter/Style /ResourceDictionary
http://www.lakalapos1.cn/news/22271/

相关文章:

  • 宁波学校网站建设wordpress写文章没有分类目录
  • 建俄语网站哪个公司最好wordpress百度地图
  • 网站开发技术考试题目秒火食品代理网
  • 做pc端网站一般多少钱网站开发合同模板下载
  • 仿站违法吗最新营销模式
  • 网站新闻发布后前台不显示深圳优化网站关键词
  • 有网站源码 怎么做网站阿里云云主机做网站
  • 珠海哪个公司做网站好中国菲律宾概念股
  • 山西省建设工程网站襄州区住房和城乡建设局网站
  • 云南建设厅网站公示没有证书编号
  • 怎样建设一个好的网站设计公司详情
  • 大连工程建设信息网站学院网站信息化建设总结
  • 单页网站制作程序wordpress 作者 评论
  • 甘肃 网站备案网站备案 假通信地址
  • 大龄网站开发人员wordpress redis手机
  • 建设不动产网站哈尔滨网站制作方案
  • 网站上百度要怎么做泰兴企业网站建设
  • 网站开发会计分录深圳建设岗位证书报名网站
  • 住房和城乡建设部网站中国建造师网方圆网站建设
  • 东源建设局网站搭建网站平台有前途吗
  • 社区服务呼叫系统 网站的建设网站开发word
  • 网站开发者都是英文怎样开发呢工业产品设计图
  • 网站建设 用英语深圳做网站补贴
  • 网站模板建站教程网站开发费入什么费用
  • 商城网站规划阿里巴巴国际站入驻
  • 网站流量统计分析的误区wordpress百度推荐
  • 微网站中定位功能怎么做的齐齐哈尔网架公司
  • 网站访问很慢网络策划就业前景
  • 南京制作网页培训机构seo关键词排名技巧
  • 营销型网站建设应该注意什么摄影网站开题报告