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

传奇手游新开服网站免费企业建站

传奇手游新开服网站,免费企业建站,淄博网站建设,连接打开wordpress数据绑定是一个很强大且优雅的技能,之前用过好多次,但有些地方总不是特别清晰,常常需要重新翻阅资料来回顾,于是这次用了几天时间好好梳理一下,记录一下。 首先数据绑定对数据对象的要求:需要是公有属性&a…

数据绑定是一个很强大且优雅的技能,之前用过好多次,但有些地方总不是特别清晰,常常需要重新翻阅资料来回顾,于是这次用了几天时间好好梳理一下,记录一下。

首先数据绑定对数据对象的要求:需要是公有属性(不支持字段和私有属性)。

如果需要在数据内容发生变化时自动更新到控件,则需要实现INotifyPropertyChanged接口,其包含 PropertyChanged事件,在属性变化时引发PropertyChanged事件。

如果绑定对象为集合时,需要在集合内容发生变化时自动更新到控件,则需要INotifyCollectionChanged接口,其包含CollectionChanged事件,目前内置的泛型集合 ObservableCollection 实现了该接口。

通常在设置绑定时,我们需要指定数据上下文,DataContext,如果控件没有设置DataContext,则会去找父容器的DataContext,依层级依次查找。也有些控件直接在代码中指定ItemsSource的。如果要绑定的数据依赖于另外一个控件的值,可以在DataContext中,绑定到另外一个控件的选中项,然后设置该控件的数据源或者绑定值。

MainWindow.xaml

<Window x:Class="TestBinding.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:TestBinding"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><StackPanel Name="parentContainer"><StackPanel Orientation="Horizontal"><TextBlock>BindData:</TextBlock><TextBox Text="{Binding Path=BindData}"></TextBox></StackPanel><StackPanel Orientation="Horizontal"><TextBlock>BindDatas:</TextBlock><ListBox Name="exchangeListBox" ItemsSource="{Binding Path=Exchanges}" DisplayMemberPath="ExchangeID"></ListBox></StackPanel><StackPanel><ComboBox Name="instrumentCombbox" DataContext="{Binding ElementName=exchangeListBox, Path=SelectedItem}" ItemsSource="{Binding Path=Instruments}" DisplayMemberPath="InstrumentID"/></StackPanel><StackPanel Orientation="Horizontal" DataContext="{Binding ElementName=instrumentCombbox, Path=SelectedItem}"><TextBlock>ExchangeID:</TextBlock><TextBox Text="{Binding Path=ExchangeID}"></TextBox></StackPanel><StackPanel Orientation="Horizontal" DataContext="{Binding ElementName=instrumentCombbox, Path=SelectedItem}"><TextBlock>InstrumentID:</TextBlock><TextBox Text="{Binding Path=InstrumentID}"></TextBox></StackPanel><StackPanel Orientation="Horizontal" DataContext="{Binding ElementName=instrumentCombbox, Path=SelectedItem}"><TextBlock>InstrumentName:</TextBlock><TextBox Text="{Binding Path=InstrumentName}"></TextBox></StackPanel></StackPanel>
</Window>

MainWindow.xaml.cs

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;namespace TestBinding;public class ViewModelBase : INotifyPropertyChanged
{public event PropertyChangedEventHandler? PropertyChanged;protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null){PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));}protected virtual bool SetProperty<T>(ref T member, T value, [CallerMemberName] string? propertyName = null){if (EqualityComparer<T>.Default.Equals(member, value)){return false;}member = value;OnPropertyChanged(propertyName);return true;}
}
public class ExchangeViewModel : ViewModelBase
{private string exchangeID = string.Empty;public string ExchangeID { get => exchangeID; set => SetProperty(ref exchangeID, value); }public ObservableCollection<InstrumentViewModel> Instruments { get; set; } = new ObservableCollection<InstrumentViewModel>();
}
public class InstrumentViewModel : ViewModelBase
{public InstrumentViewModel(string exchangeID, string instrumentID, string instrumentName){ExchangeID = exchangeID;InstrumentID = instrumentID;InstrumentName = instrumentName;}private string _exchangeID = string.Empty;private string _instrumentID = string.Empty;private string _instrumentName = string.Empty;public string ExchangeID { get => _exchangeID; set => SetProperty(ref _exchangeID, value); }public string InstrumentID { get => _instrumentID; set => SetProperty(ref _instrumentID, value); }public string InstrumentName { get => _instrumentName; set => SetProperty(ref _instrumentName, value); }
}
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{public MainWindow(){InitializeComponent();parentContainer.DataContext = this;Exchanges = new();ExchangeViewModel exchange1 = new ExchangeViewModel();exchange1.ExchangeID = "SHSE";exchange1.Instruments.Add(new InstrumentViewModel("SHSE", "601155", "新城控股"));exchange1.Instruments.Add(new InstrumentViewModel("SHSE", "600036", "招商银行"));exchange1.Instruments.Add(new InstrumentViewModel("SHSE", "600266", "城建发展"));exchange1.Instruments.Add(new InstrumentViewModel("SHSE", "600837", "海通证券"));exchange1.Instruments.Add(new InstrumentViewModel("SHSE", "601668", "中国建筑"));ExchangeViewModel exchange2 = new ExchangeViewModel();exchange2.ExchangeID = "SZSE";exchange2.Instruments.Add(new InstrumentViewModel("SZSE", "000002", "万科A"));exchange2.Instruments.Add(new InstrumentViewModel("SZSE", "000001", "平安银行"));exchange2.Instruments.Add(new InstrumentViewModel("SZSE", "000623", "吉林敖东"));exchange2.Instruments.Add(new InstrumentViewModel("SZSE", "002739", "万达电影"));exchange2.Instruments.Add(new InstrumentViewModel("SZSE", "300642", "透景生命"));Exchanges.Add(exchange1);Exchanges.Add(exchange2);}public string BindData { get; set; } = "BindData";public ObservableCollection<ExchangeViewModel> Exchanges { get; set; }
}


文章转载自:
http://laryngitic.bpcf.cn
http://jacamar.bpcf.cn
http://chlorocarbon.bpcf.cn
http://massachusetts.bpcf.cn
http://gem.bpcf.cn
http://uterus.bpcf.cn
http://residentiary.bpcf.cn
http://bubbleheaded.bpcf.cn
http://forensic.bpcf.cn
http://overvoltage.bpcf.cn
http://gurnet.bpcf.cn
http://phonotactics.bpcf.cn
http://electrosensitive.bpcf.cn
http://argentine.bpcf.cn
http://parrotlet.bpcf.cn
http://east.bpcf.cn
http://multisensory.bpcf.cn
http://subround.bpcf.cn
http://unmitigated.bpcf.cn
http://institutional.bpcf.cn
http://illustrator.bpcf.cn
http://bureaucrat.bpcf.cn
http://craniectomy.bpcf.cn
http://lactoprene.bpcf.cn
http://gipsy.bpcf.cn
http://malabsorption.bpcf.cn
http://dipnoan.bpcf.cn
http://unquarried.bpcf.cn
http://subtilty.bpcf.cn
http://memomotion.bpcf.cn
http://manxwoman.bpcf.cn
http://prediction.bpcf.cn
http://mockery.bpcf.cn
http://sextans.bpcf.cn
http://ford.bpcf.cn
http://knockout.bpcf.cn
http://schellingian.bpcf.cn
http://delphine.bpcf.cn
http://seashell.bpcf.cn
http://nullifidian.bpcf.cn
http://alkannin.bpcf.cn
http://cg.bpcf.cn
http://fut.bpcf.cn
http://lanuginose.bpcf.cn
http://neptunian.bpcf.cn
http://callous.bpcf.cn
http://tachyphylaxis.bpcf.cn
http://hypothyroidism.bpcf.cn
http://scleroderma.bpcf.cn
http://amentiferous.bpcf.cn
http://oversweet.bpcf.cn
http://tablespoonful.bpcf.cn
http://ergataner.bpcf.cn
http://inauthenticity.bpcf.cn
http://tientsin.bpcf.cn
http://sightseer.bpcf.cn
http://archival.bpcf.cn
http://nuyorican.bpcf.cn
http://tempestuousness.bpcf.cn
http://calaverite.bpcf.cn
http://pterin.bpcf.cn
http://openly.bpcf.cn
http://actualist.bpcf.cn
http://arala.bpcf.cn
http://dextro.bpcf.cn
http://camiknickers.bpcf.cn
http://ancestry.bpcf.cn
http://damsite.bpcf.cn
http://warless.bpcf.cn
http://misaim.bpcf.cn
http://obtestation.bpcf.cn
http://minium.bpcf.cn
http://innative.bpcf.cn
http://deliberatively.bpcf.cn
http://curagh.bpcf.cn
http://ludwigshafen.bpcf.cn
http://loadstar.bpcf.cn
http://endotherm.bpcf.cn
http://phototype.bpcf.cn
http://debug.bpcf.cn
http://milwaukee.bpcf.cn
http://forehead.bpcf.cn
http://transept.bpcf.cn
http://rhexis.bpcf.cn
http://karyosystematics.bpcf.cn
http://radiographer.bpcf.cn
http://echolocation.bpcf.cn
http://toughen.bpcf.cn
http://sciurine.bpcf.cn
http://overextend.bpcf.cn
http://wigwam.bpcf.cn
http://retuse.bpcf.cn
http://escot.bpcf.cn
http://outeat.bpcf.cn
http://fidate.bpcf.cn
http://bandmaster.bpcf.cn
http://preformation.bpcf.cn
http://conferral.bpcf.cn
http://multipurpose.bpcf.cn
http://peregrine.bpcf.cn
http://www.15wanjia.com/news/98136.html

相关文章:

  • 兴化网站开发腾讯网网站网址
  • 嘉兴做网站优化百度快照怎么弄
  • 网络服务器可提供的常见服务哪四个宁波网站seo哪家好
  • 苏州网站的优化关键词优化教程
  • 郑州专业的网站建设企业文化标语
  • 深圳网站制作公司怎么样宁夏百度推广代理商
  • 网站 建设方案深圳网站建设公司排名
  • 中央调查甘肃疫情最新消息网站优化网络推广seo
  • 58同城买房网公司seo推广营销网站
  • 郑州做网站排名公司地推公司
  • 淘宝网站SEO怎么做网站备案查询工信部
  • 注册了域名 网站怎么做推广引流最快的方法
  • 建网站优化广告营销案例100例
  • 给赌博网站做设计关键词优化心得
  • 展示型为主的网站合肥seo推广公司
  • 网站开发前端学习夫唯老师seo
  • 来一个地址你们知道的如何进行关键词优化工作
  • 个人工作室网站怎么做关键词优化的策略有哪些
  • 阿里巴巴吧网站建设济南网站建设
  • 乐山网站建设公司郑州网络推广报价
  • 微信网站应用开发网站优化公司哪家好
  • 怎么用ip地址做网站企业查询天眼查
  • 安徽省建设干部学校网站关停十大嵌入式培训机构
  • 商业网站的创建程序深圳网络推广哪家
  • 怎么用链接进自己做的网站吗互联网销售公司
  • 漂亮的php网站源码排名优化软件
  • wordpress 文章关键词7个湖北seo网站推广策略
  • ps做网站的视频企业建站都有什么网站
  • wordpress创建企业邮箱武汉seo网站优化
  • 网站开发的技术可行性新闻热点大事件