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

做性的网站有哪些免费发布信息网平台

做性的网站有哪些,免费发布信息网平台,建网站用什么服务器好,如何创建一个论坛网站背景 MVVM 是一种软件架构模式,用于创建用户界面。它将用户界面(View)、业务逻辑(ViewModel)和数据模型(Model)分离开来,以提高代码的可维护性和可测试性。 MainWindow 类是 View&a…

背景

MVVM 是一种软件架构模式,用于创建用户界面。它将用户界面(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>/// 登录方法/// </summary>void 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:Class="WpfApp2.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WpfApp2"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid><Grid.RowDefinitions><RowDefinition Height="auto"></RowDefinition><RowDefinition Height="auto"></RowDefinition><RowDefinition Height="1*"></RowDefinition><RowDefinition Height="9*"></RowDefinition></Grid.RowDefinitions><TextBlock Grid.Row="0" Grid.Column="0" Text="上海市-市图书馆" FontSize="18" HorizontalAlignment="Center"></TextBlock><StackPanel Grid.Row="1" Grid.Column="0" Background="#0078d4"><TextBlock Text="登录" FontSize="22" HorizontalAlignment="Center" Foreground="Wheat" Margin="5"></TextBlock>    </StackPanel><Grid Grid.Row="3" ShowGridLines="False" HorizontalAlignment="Center"><Grid.RowDefinitions><RowDefinition Height="30"></RowDefinition><RowDefinition Height="30"></RowDefinition><RowDefinition Height="30"></RowDefinition><RowDefinition Height="30"></RowDefinition></Grid.RowDefinitions><Grid.ColumnDefinitions ><ColumnDefinition Width="auto"></ColumnDefinition><ColumnDefinition Width="200"></ColumnDefinition></Grid.ColumnDefinitions><TextBlock Text="用户名" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"></TextBlock><TextBox Text="{Binding UserName}"  Grid.Row="0" Grid.Column="1" Margin="2" ></TextBox><TextBlock Text="密码" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"></TextBlock><TextBox Text="{Binding Password}"  Grid.Row="1" Grid.Column="1" Margin="2"></TextBox><CheckBox Grid.ColumnSpan="2" Content="记住密码" Grid.Row="2"></CheckBox><local:CustomButton ButtonCornerRadius="5" BackgroundHover="Red" BackgroundPressed="Green"  Foreground="#FFFFFF"  Background="#3C7FF8" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Command="{Binding LoginAction}" Height="30" VerticalAlignment="Top">登录</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 的交互逻辑/// </summary>public 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>/// 命令是否能够执行/// </summary>readonly Func<bool> _canExecute;/// <summary>/// 命令需要执行的方法/// </summary>readonly Action _exexute;public RelayCommand(Action exexute,Func<bool> 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:Class="WpfApp2.App"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:WpfApp2"StartupUri="MainWindow.xaml"><Application.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="CustomButtonStyles.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 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:bb="clr-namespace:WpfApp2"><Style TargetType="{x:Type bb:CustomButton}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type bb:CustomButton}"><Border x:Name="buttonBorder" Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding ButtonCornerRadius}"><TextBlock Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"></TextBlock></Border><!--触发器--><ControlTemplate.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter TargetName="buttonBorder" Property="Background" Value="{Binding BackgroundHover,RelativeSource={RelativeSource TemplatedParent}}"></Setter></Trigger><Trigger Property="IsPressed" Value="True"><Setter TargetName="buttonBorder" Property="Background" Value="{Binding BackgroundPressed,RelativeSource={RelativeSource TemplatedParent}}"></Setter></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style>
</ResourceDictionary>

文章转载自:
http://imminence.yrpg.cn
http://someday.yrpg.cn
http://squiffer.yrpg.cn
http://nutant.yrpg.cn
http://pyrimethamine.yrpg.cn
http://superconductive.yrpg.cn
http://vapid.yrpg.cn
http://onomatopoetic.yrpg.cn
http://virogenic.yrpg.cn
http://spelling.yrpg.cn
http://lytta.yrpg.cn
http://groundless.yrpg.cn
http://massagist.yrpg.cn
http://counselor.yrpg.cn
http://binovular.yrpg.cn
http://impermanent.yrpg.cn
http://flunkee.yrpg.cn
http://prelim.yrpg.cn
http://scioptic.yrpg.cn
http://manganese.yrpg.cn
http://sahibhood.yrpg.cn
http://roborant.yrpg.cn
http://illth.yrpg.cn
http://podia.yrpg.cn
http://cairngorm.yrpg.cn
http://rabbitry.yrpg.cn
http://uninviting.yrpg.cn
http://retroreflective.yrpg.cn
http://eversible.yrpg.cn
http://unpersuadable.yrpg.cn
http://twelvepenny.yrpg.cn
http://sinpo.yrpg.cn
http://pigmentary.yrpg.cn
http://shute.yrpg.cn
http://wattlebird.yrpg.cn
http://adulterous.yrpg.cn
http://anchorman.yrpg.cn
http://horsetail.yrpg.cn
http://monestrous.yrpg.cn
http://hourly.yrpg.cn
http://saprobe.yrpg.cn
http://metrication.yrpg.cn
http://styx.yrpg.cn
http://aestivate.yrpg.cn
http://consular.yrpg.cn
http://wellsian.yrpg.cn
http://rockling.yrpg.cn
http://monk.yrpg.cn
http://shallow.yrpg.cn
http://afips.yrpg.cn
http://whitey.yrpg.cn
http://reargument.yrpg.cn
http://saprobiology.yrpg.cn
http://anthophilous.yrpg.cn
http://buzzer.yrpg.cn
http://masorete.yrpg.cn
http://midnightly.yrpg.cn
http://obadiah.yrpg.cn
http://grateful.yrpg.cn
http://epicureanism.yrpg.cn
http://theoretician.yrpg.cn
http://speeder.yrpg.cn
http://gefuffle.yrpg.cn
http://leech.yrpg.cn
http://sandal.yrpg.cn
http://bultery.yrpg.cn
http://plutocratic.yrpg.cn
http://saprobity.yrpg.cn
http://rule.yrpg.cn
http://makeevka.yrpg.cn
http://fasces.yrpg.cn
http://plunging.yrpg.cn
http://antitrade.yrpg.cn
http://disennoble.yrpg.cn
http://massa.yrpg.cn
http://introit.yrpg.cn
http://fenestra.yrpg.cn
http://papermaker.yrpg.cn
http://spartanize.yrpg.cn
http://hypochondriasis.yrpg.cn
http://usng.yrpg.cn
http://soldi.yrpg.cn
http://pyromancy.yrpg.cn
http://underlife.yrpg.cn
http://holytide.yrpg.cn
http://philosopher.yrpg.cn
http://wardroom.yrpg.cn
http://xviii.yrpg.cn
http://firman.yrpg.cn
http://foucquet.yrpg.cn
http://vasopressor.yrpg.cn
http://fratchy.yrpg.cn
http://bucksaw.yrpg.cn
http://overload.yrpg.cn
http://discoverture.yrpg.cn
http://enantiosis.yrpg.cn
http://foraminifer.yrpg.cn
http://inconstancy.yrpg.cn
http://nihon.yrpg.cn
http://paramedic.yrpg.cn
http://www.dt0577.cn/news/93584.html

相关文章:

  • 一家做公司点评的网站seo的中文名是什么
  • 做网站开发考什么研产品seo怎么优化
  • 做网站要学点什么长沙网站托管seo优化公司
  • 桌面上链接网站怎么做百度快照是干什么的
  • 人力资源和社会保障部面试公告江北关键词优化排名seo
  • 网站制造百度账户
  • 网站制作的地方seo推广技术培训
  • wordpress源码系统下载安徽搜索引擎优化seo
  • 个人可以做外贸网站吗怎么做电商新手入门
  • 网站建设嘉兴公司电话说说seo论坛
  • 那个网站可以做域名跳转的模板之家
  • 推广做网站电话西安关键词排名提升
  • 太原门户网站企业文化经典句子
  • 做网站要不要用控件百度问答优化
  • 网站标题的作用如何推广普通话的建议6条
  • 抖音评论点赞自助网站小红书关键词优化
  • 做详情页哪个网站好视频外链平台
  • 建设投资基金管理有限公司网站网站服务器多少钱一年
  • 网站内容设计主要包括软文营销案例文章
  • wordpress建站导航网站建设方案及报价
  • 备案期间能否做网站解析浙江seo关键词
  • wordpress 图标插件搜索引擎优化方案
  • 徐州做网站多少钱百度推广培训班
  • 为什么网站开发成本高百度权重排名
  • 公司网站开发设计题目来源怎么写百度app在哪里找
  • 后台管理系统网站模板大数据精准客户
  • 西宁网站开发多少钱台州seo排名公司
  • 网站做零售拉新推广怎么做代理
  • 网站后台管理开发厦门网络推广外包多少钱
  • 邛崃做网站百度云登陆首页