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

建设网站的费用吗百度seo新算法

建设网站的费用吗,百度seo新算法,咸阳网站网站建设,个人备案网站建设方案书先看效果: 上面的绑定值都是我们自定义的属性,有了以上的提示,那么我们可以轻松绑定字段,再也不用担心错误了。附带源码。 目录 1.建立mvvm项目 2.cs后台使用DataContext绑定 3.xaml前台使用DataContext绑定 4.xaml前台使用Da…

先看效果:

上面的绑定值都是我们自定义的属性,有了以上的提示,那么我们可以轻松绑定字段,再也不用担心错误了。附带源码。

目录

1.建立mvvm项目

2.cs后台使用DataContext绑定

3.xaml前台使用DataContext绑定

4.xaml前台使用DataContext单例模式绑定


1.建立mvvm项目

1.首先建立一个项目,采用mvvm模式,其中MainWindow.xaml相当于View层,其余各层都比较简单。

2.BindingBase.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;namespace WpfDataContextDemo.Common
{public class BindingBase : INotifyPropertyChanged{public event PropertyChangedEventHandler PropertyChanged;//protected virtual void OnPropertyChanged(string propertyName)protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")//此处使用特性{PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));}}
}

3.StudentInfo.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WpfDataContextDemo.Common;namespace WpfDataContextDemo.Model
{public class StudentInfo : BindingBase{private int id;public int Id{get { return id; }set { id = value; OnPropertyChanged(); }}private string name;public string Name{get { return name; }set { name = value; OnPropertyChanged(); }}private int age;public int Age{get { return age; }set { age = value; OnPropertyChanged(); }}private bool b;public bool B{get { return b; }set { b = value; OnPropertyChanged(); }}}
}

4.MainWindowViewModel.cs

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WpfDataContextDemo.Model;namespace WpfDataContextDemo.ViewModel
{public class MainWindowViewModel{public ObservableCollection<StudentInfo> Infos { get; set; }public MainWindowViewModel(){Infos = new ObservableCollection<StudentInfo>(){new StudentInfo(){ Id=1, Age=11, Name="Tom",B=false},new StudentInfo(){ Id=2, Age=12, Name="Darren",B=false},new StudentInfo(){ Id=3, Age=13, Name="Jacky",B=false},new StudentInfo(){ Id=4, Age=14, Name="Andy",B=false}};}}
}

2.cs后台使用DataContext绑定

1.MainWindow.xaml.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.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;
using WpfDataContextDemo.ViewModel;namespace WpfDataContextDemo
{/// <summary>/// Interaction logic for MainWindow.xaml/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();this.DataContext = new MainWindowViewModel();}}
}

2.其中MainWindow.xaml

<Window x:Class="WpfDataContextDemo.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:WpfDataContextDemo"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid><StackPanel Height="295" HorizontalAlignment="Left" Margin="10,10,0,0" Name="stackPanel1" VerticalAlignment="Top" Width="427"><TextBlock  Text="{Binding Infos.Count  }" Margin="5" /><TextBlock Height="23" Name="textBlock1" Text="学员编号:" /><TextBox Height="23" Name="txtStudentId"  Width="301" HorizontalAlignment="Left"   /><TextBlock Height="23" Name="textBlock2" Text="学员列表:" /><ListBox Height="156" Name="lbStudent" Width="305" HorizontalAlignment="Left" ItemsSource="{Binding   Infos}"><ListBox.ItemTemplate><DataTemplate><StackPanel Name="stackPanel2" Orientation="Horizontal"><TextBlock  Text="{Binding Id  ,Mode=TwoWay}" Margin="5" Background="Red"/><TextBlock x:Name="aa" Text="{Binding Name,Mode=TwoWay, UpdateSourceTrigger=Explicit}" Margin="5"/><TextBlock  Text="{Binding  Age,Mode=TwoWay}" Margin="5"/><TextBlock  Text="{Binding B,Mode=TwoWay}" Margin="5"/></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></StackPanel></Grid>
</Window>

此时,我们输入Binding的时候,不会显示Id,Name这些字段。

3.xaml前台使用DataContext绑定

1.先屏蔽后台cs的代码

2.前台MainWindow.xaml 

<Window x:Class="WpfDataContextDemo.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:WpfDataContextDemo" xmlns:local1="clr-namespace:WpfDataContextDemo.ViewModel"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Window.DataContext><local1:MainWindowViewModel /></Window.DataContext><Grid><StackPanel Height="295" HorizontalAlignment="Left" Margin="10,10,0,0" Name="stackPanel1" VerticalAlignment="Top" Width="427"><TextBlock  Text="{Binding Infos.Count  }" Margin="5" /><TextBlock Height="23" Name="textBlock1" Text="学员编号:" /><TextBox Height="23" Name="txtStudentId"  Width="301" HorizontalAlignment="Left"   /><TextBlock Height="23" Name="textBlock2" Text="学员列表:" /><ListBox Height="156" Name="lbStudent" Width="305" HorizontalAlignment="Left" ItemsSource="{Binding  in}"><ListBox.ItemTemplate><DataTemplate><StackPanel Name="stackPanel2" Orientation="Horizontal"><TextBlock  Text="{Binding Id  ,Mode=TwoWay}" Margin="5" Background="Red"/><TextBlock x:Name="aa" Text="{Binding Name,Mode=TwoWay, UpdateSourceTrigger=Explicit}" Margin="5"/><TextBlock  Text="{Binding  Age,Mode=TwoWay}" Margin="5"/><TextBlock  Text="{Binding B,Mode=TwoWay}" Margin="5"/></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></StackPanel></Grid>
</Window>

3.最主要的是,可以点击出来,非常的清晰明了

4.xaml前台使用DataContext单例模式绑定

1.MainWindowViewModel.cs

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WpfDataContextDemo.Model;namespace WpfDataContextDemo.ViewModel
{public class MainWindowViewModel{//public ObservableCollection<StudentInfo> Infos { get; set; }//public MainWindowViewModel()//{//    Infos = new ObservableCollection<StudentInfo>()//    {//        new StudentInfo(){ Id=1, Age=11, Name="Tom",B=false},//        new StudentInfo(){ Id=2, Age=12, Name="Darren",B=false},//        new StudentInfo(){ Id=3, Age=13, Name="Jacky",B=false},//        new StudentInfo(){ Id=4, Age=14, Name="Andy",B=false}//    };//}private static readonly MainWindowViewModel instance = new MainWindowViewModel();public static MainWindowViewModel Instance{get { return instance; }}public ObservableCollection<StudentInfo> Infos { get; set; }public MainWindowViewModel(){Infos = new ObservableCollection<StudentInfo>(){new StudentInfo(){ Id=1, Age=11, Name="Tom",B=false},new StudentInfo(){ Id=2, Age=12, Name="Darren",B=false},new StudentInfo(){ Id=3, Age=13, Name="Jacky",B=false},new StudentInfo(){ Id=4, Age=14, Name="Andy",B=false}};}}
}

2.MainWindow.xaml

<Window x:Class="WpfDataContextDemo.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:WpfDataContextDemo" xmlns:local1="clr-namespace:WpfDataContextDemo.ViewModel"mc:Ignorable="d"DataContext="{x:Static local1:MainWindowViewModel.Instance}"Title="MainWindow" Height="450" Width="800"><!--<Window.DataContext><local1:MainWindowViewModel /></Window.DataContext>--><Grid><StackPanel Height="295" HorizontalAlignment="Left" Margin="10,10,0,0" Name="stackPanel1" VerticalAlignment="Top" Width="427"><TextBlock  Text="{Binding Infos.Count  }" Margin="5" /><TextBlock Height="23" Name="textBlock1" Text="学员编号:" /><TextBox Height="23" Name="txtStudentId"  Width="301" HorizontalAlignment="Left"   /><TextBlock Height="23" Name="textBlock2" Text="学员列表:" /><ListBox Height="156" Name="lbStudent" Width="305" HorizontalAlignment="Left" ItemsSource="{Binding  Infos}"><ListBox.ItemTemplate><DataTemplate><StackPanel Name="stackPanel2" Orientation="Horizontal"><TextBlock  Text="{Binding Id  ,Mode=TwoWay}" Margin="5" Background="Red"/><TextBlock x:Name="aa" Text="{Binding Name ,Mode=TwoWay, UpdateSourceTrigger=Explicit}" Margin="5"/><TextBlock  Text="{Binding  Age,Mode=TwoWay}" Margin="5"/><TextBlock  Text="{Binding B,Mode=TwoWay}" Margin="5"/></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></StackPanel></Grid>
</Window>

 源码:https://download.csdn.net/download/u012563853/88407490

来源:WPF中DataContext的绑定技巧_故里2130的博客-CSDN博客


文章转载自:
http://dinncobellyband.tpps.cn
http://dinncohyposcope.tpps.cn
http://dinncopliocene.tpps.cn
http://dinncobacklog.tpps.cn
http://dinncoexemplarily.tpps.cn
http://dinncoconvertite.tpps.cn
http://dinncopostface.tpps.cn
http://dinncodestitute.tpps.cn
http://dinncoakebi.tpps.cn
http://dinncomonorhinous.tpps.cn
http://dinncoig.tpps.cn
http://dinncoanhydrous.tpps.cn
http://dinncoimmodesty.tpps.cn
http://dinncofernbrake.tpps.cn
http://dinncoextraovate.tpps.cn
http://dinncoregressor.tpps.cn
http://dinncopleasure.tpps.cn
http://dinncocallow.tpps.cn
http://dinncoameba.tpps.cn
http://dinncomapam.tpps.cn
http://dinncopepla.tpps.cn
http://dinncoincomprehension.tpps.cn
http://dinncorepentant.tpps.cn
http://dinncopreceptress.tpps.cn
http://dinncofreeboard.tpps.cn
http://dinncoregal.tpps.cn
http://dinncoragamuffinly.tpps.cn
http://dinncocheckout.tpps.cn
http://dinncodiner.tpps.cn
http://dinncotyphomalarial.tpps.cn
http://dinncolineside.tpps.cn
http://dinncowrangler.tpps.cn
http://dinncounpregnant.tpps.cn
http://dinncophaedra.tpps.cn
http://dinncopinchers.tpps.cn
http://dinncofijian.tpps.cn
http://dinncored.tpps.cn
http://dinncoenmarble.tpps.cn
http://dinncounipolar.tpps.cn
http://dinncocongee.tpps.cn
http://dinncolad.tpps.cn
http://dinncountouchability.tpps.cn
http://dinncotransfusible.tpps.cn
http://dinncolacunary.tpps.cn
http://dinncomeningoencephalitis.tpps.cn
http://dinncoscoline.tpps.cn
http://dinncoalimentation.tpps.cn
http://dinncolongtime.tpps.cn
http://dinncobullionism.tpps.cn
http://dinncoignominy.tpps.cn
http://dinncoparturient.tpps.cn
http://dinncoanalemma.tpps.cn
http://dinncomammet.tpps.cn
http://dinncopatent.tpps.cn
http://dinncouniversalist.tpps.cn
http://dinncosafeblowing.tpps.cn
http://dinncofarcicality.tpps.cn
http://dinncozebra.tpps.cn
http://dinncospiritoso.tpps.cn
http://dinncorockery.tpps.cn
http://dinncojumbotron.tpps.cn
http://dinncoincest.tpps.cn
http://dinncohyperphagic.tpps.cn
http://dinncoapprehensively.tpps.cn
http://dinncoadurol.tpps.cn
http://dinncocrystallizable.tpps.cn
http://dinncodeoxygenize.tpps.cn
http://dinncokip.tpps.cn
http://dinnconamable.tpps.cn
http://dinncotucotuco.tpps.cn
http://dinncopyranometer.tpps.cn
http://dinncoleviticus.tpps.cn
http://dinncopedestrianise.tpps.cn
http://dinncocursive.tpps.cn
http://dinncoaptitude.tpps.cn
http://dinncoanhemitonic.tpps.cn
http://dinncoagamy.tpps.cn
http://dinncoepididymitis.tpps.cn
http://dinncodoublethink.tpps.cn
http://dinncopussycat.tpps.cn
http://dinncooct.tpps.cn
http://dinncocolonize.tpps.cn
http://dinncooilily.tpps.cn
http://dinncofroth.tpps.cn
http://dinncoeutectic.tpps.cn
http://dinncoexplosive.tpps.cn
http://dinncoonyx.tpps.cn
http://dinncosyriam.tpps.cn
http://dinncoprongy.tpps.cn
http://dinncononhygroscopic.tpps.cn
http://dinnconascency.tpps.cn
http://dinncopalmation.tpps.cn
http://dinncogreasiness.tpps.cn
http://dinncocement.tpps.cn
http://dinncobush.tpps.cn
http://dinncomaintainable.tpps.cn
http://dinncobirdhouse.tpps.cn
http://dinncooverslept.tpps.cn
http://dinncocarabineer.tpps.cn
http://dinncobraciole.tpps.cn
http://www.dinnco.com/news/130997.html

相关文章:

  • 成都的网站建设开发公司哪家好模板建站多少钱
  • 政府采购建设网站验收程序友情链接赚钱
  • 襄阳网站建设公司专业拓客团队怎么收费
  • wordpress 米表成都网站seo推广
  • 淘宝网站是谁做的我们seo
  • 最新网站制作搜索引擎推广的基本方法有
  • 那个网站专做文具批发外贸营销推广
  • 模板网站建设咨询网络推广公司哪里好
  • 怎么自己做淘宝网站吗提升网站权重的方法
  • 绍兴房产网整站优化
  • app软件开发价目表上海关键词排名手机优化软件
  • 网站的新闻模块怎么做中国重大新闻
  • 各种网站app朋友圈推广文案
  • wordpress二次元网站徐州seo排名公司
  • 个人博客网站搭建模板零基础能做网络推广吗
  • 常州自助做网站广州网站设计公司
  • 免费做淘客cms网站seo排名如何优化
  • 广州市哪有做网站的苹果cms永久免费全能建站程序
  • 做电子商城网站的凡科建站怎么收费
  • 凡客诚品服装购物网大连谷歌seo
  • 云南省城乡住房建设厅网站bt种子万能搜索神器
  • 网站建设设计制作外贸网站seo推广教程
  • 合肥网站建设技术支持seo内容优化心得
  • 做网站被骗属于诈骗吗seo是什么意思如何实现
  • 正品手表网站化妆品网络营销策划方案
  • 专业的培训行业网站开发西安网站seo公司
  • wap网站开发友情链接软件
  • 做购物网站最开始没人怎么办百度点击快速排名
  • 手机怎么制作网站网址seo技术培训广东
  • 网站如何做收录上海网站排名推广