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

服务器建设网站软件下载百度指数怎么提升

服务器建设网站软件下载,百度指数怎么提升,网站支付怎么做,网站设计的优化一、绑定模式 绑定模式以及模式的使用效果。 示例如下是根据ListBox中的选中项,去改变TextBlock的背景色。将 TextBlock 的背景色绑定到在 ListBox 中选择的颜色。在下面的代码中针对TextBlock的 Background 属性使用绑定语法绑定从 ListBox 中选择的值。代码如下。…

一、绑定模式
绑定模式以及模式的使用效果。
示例如下是根据ListBox中的选中项,去改变TextBlock的背景色。将 TextBlock 的背景色绑定到在 ListBox 中选择的颜色。在下面的代码中针对TextBlock的 Background 属性使用绑定语法绑定从 ListBox 中选择的值。代码如下。

<StackPanel Grid.Row="1"><TextBlock Width="248" Height="24" Text="颜色:"TextWrapping="Wrap"/><ListBox x:Name="listColor" Width="248" Height="56"><ListBoxItem Content="Blue"/><ListBoxItem Content="Red"/><ListBoxItem Content="Green"/><ListBoxItem Content="Gray"/><ListBoxItem Content="Cyan"/><ListBoxItem Content="GreenYellow"/><ListBoxItem Content="Orange"/></ListBox><TextBlock Width="248" Height="24" Text="改变背景色:" /><TextBlock Width="248" Height="24" Background="{Binding ElementName=listColor,             Path=SelectedItem.Content, Mode=OneWay}"></TextBlock></StackPanel>

这里写图片描述

接下来我们对上面的示例进行一些修改:
1) 同一个数据源绑定到两个或多个控件上。如我们的示例中把ListBox的选中项绑定到TextBox与TextBlock。
2) 在绑定语法中增加一个 Mode 属性--绑定模式。对于我们的示例,我们把TextBlock的绑定语法中的Mode属性设为 OneWay 。把TextBox的绑定语法中的Mode属性设为TwoWay

对于绑定模式Mode说明:
1)OneWay 绑定时,每当数据源(ListBox)发生变化时,数据就会从数据源流向目标(TextBlock)。
2)OneTime(仅变更一次) 绑定也会将数据从源发送到目标;但是,仅当启动了应用程序或 DataContext 发生更改时才会如此操作,因此,它不会侦听源中的更改通知。
3)OneWayToSource 绑定会将数据从目标发送到数据源。
4)TwoWay 绑定会将源数据发送到目标,但如果目标属性的值发生变化,则会将它们发回给源。

下面是修改后的示例代码,功能是将 TextBlock (OneWay) 和 TextBox (TwoWay) 绑定到 ListBox 的代码:

<StackPanel Grid.Row="1"><TextBlock Width="248" Height="24" Text="颜色:"TextWrapping="Wrap"/><ListBox x:Name="listColor" Width="248" Height="56"><ListBoxItem Content="Blue"/><ListBoxItem Content="Red"/><ListBoxItem Content="Green"/><ListBoxItem Content="Gray"/><ListBoxItem Content="Cyan"/><ListBoxItem Content="GreenYellow"/><ListBoxItem Content="Orange"/></ListBox><TextBlock Width="248" Height="24" Text="改变背景色:" /><TextBlock Width="248" Height="24" Text="{Binding ElementName=listColor, Path=SelectedItem.Content, Mode=OneWay}"Background="{Binding ElementName=listColor, Path=SelectedItem.Content, Mode=OneWay}"></TextBlock><TextBox Name="txtTwoWay" Text="{Binding ElementName=listColor,Path=SelectedItem.Content,Mode=TwoWay}"Background="{Binding ElementName=listColor,Path=SelectedItem.Content,Mode=TwoWay}"></TextBox></StackPanel>

   图 2
在上述示例中,对TextBlock使用了 OneWay 绑定模式,只有当选择了 ListBox 中的某一项之后,应用程序将选定的 ListBoxItem(数据源)发送到 TextBlock。我不希望 TextBlock 的变更会影响到 ListBox中的内容。
我对TextBox使用 TwoWay 绑定模式,因为我希望用户在 ListBox 中选择一种颜色后,该颜色就会显示在 TextBox 中,并且其背景色也会随之相应变化。如果该用户在 TextBox 中键入了一种颜色(例如Pink),ListBox 中刚才选中的颜色名称就会被更新(即从目标到数据源),当鼠标再次点击这条修改后的数据时,新值就会被再次发送到TextBox上。这意味着 TextBlock 也会随之改变。(请参见图 2)。
这里写图片描述

如果我将 TwoWay 模式改回到 OneWay,用户则可以编辑 TextBox 中的颜色,但是不会将TextBox中输入的值去替换ListBox中选中项的值。

绑定模式小结:
1)OneWay 模式:当只想让用户看到数据,而不希望用户去修改数据时,可以采用 OneWay 模式,类似winform中的只读属性。
2)TwoWay模式:当希望用户可以对控件中的数据进行修改,同时让用户修改的数据更新到数据源(DataSet、对象、XML 或其他绑定控件)中时,可以使用 TwoWay 绑定。
3)OneWayToSource模式:如果想让用户修改数据源中的数据,而又不想使用TowWay模式,就可以使用 OneWayToSource 绑定。OneWayToSource模式允许通过在原来被看作是绑定源的对象中放置绑定表达式,从而翻转源和目标。
4)OneTime模式:当你的界面中的一系列只读控件均被绑定了数据,并且当用户刷新了数据源时,希望绑定控件中的值仍保持不变,可以使用 OneTime 绑定。此外,当源没有实现 INotifyPropertyChanged 时,OneTime 绑定模式也是一个不错的选择。

小结:绑定目标中的修改何时去修改数据源
在上面的例子中,TextBox 使用了 TwoWay 绑定模式,所以当TextBox 失去焦点时WPF会使用TextBox中的值改变ListBox中的值。如果你不想在TextBox失去焦点时,就去修改ListBox中的值,可以为 UpdateSourceTrigger 指定值,它是用于定义何时更新源的绑定属性。可以为

UpdateSourceTrigger 可以设置三个值:Explicit、LostFocus 和 PropertyChanged。
Explicit(不主动更新数据):如果将 UpdateSourceTrigger 设置为 Explicit,则不会更新源,除非 后台代码脚本中更新数据

LostFocus(丢失焦点更新数据):BindingExpression.UpdateSource 方法。设置为LostFocus ,(TextBox 控件的默认值)指示数据源绑定的控件失去焦点时才会更新。

PropertyChanged(属性值变更更新): 值绑定控件的绑定属性每次发生更改时就去更新数据源中的值。


文章转载自:
http://dinncotoolhead.ssfq.cn
http://dinncogearlever.ssfq.cn
http://dinncoalabandite.ssfq.cn
http://dinncobastille.ssfq.cn
http://dinncoterritorialise.ssfq.cn
http://dinncoclv.ssfq.cn
http://dinncobackhanded.ssfq.cn
http://dinncobudgeteer.ssfq.cn
http://dinncomenhir.ssfq.cn
http://dinncosucci.ssfq.cn
http://dinncoindustrial.ssfq.cn
http://dinncoveins.ssfq.cn
http://dinncoteniasis.ssfq.cn
http://dinnconame.ssfq.cn
http://dinncorainsuit.ssfq.cn
http://dinncocontredanse.ssfq.cn
http://dinncogand.ssfq.cn
http://dinncoswan.ssfq.cn
http://dinncolaigh.ssfq.cn
http://dinncostraitjacket.ssfq.cn
http://dinncoshoal.ssfq.cn
http://dinncohare.ssfq.cn
http://dinncobuccaneering.ssfq.cn
http://dinncowindcheater.ssfq.cn
http://dinncorhetic.ssfq.cn
http://dinncofloodway.ssfq.cn
http://dinncotetrastich.ssfq.cn
http://dinncofantasticate.ssfq.cn
http://dinncocuso.ssfq.cn
http://dinncoconditioned.ssfq.cn
http://dinncolentamente.ssfq.cn
http://dinncoocclusion.ssfq.cn
http://dinncokeynoter.ssfq.cn
http://dinncosuperexpress.ssfq.cn
http://dinncoconvertibly.ssfq.cn
http://dinncoelectrothermal.ssfq.cn
http://dinncocheckage.ssfq.cn
http://dinncoharmaline.ssfq.cn
http://dinncolaterad.ssfq.cn
http://dinncopalaeoclimatology.ssfq.cn
http://dinncodaylong.ssfq.cn
http://dinncoundercapitalize.ssfq.cn
http://dinncoropewalking.ssfq.cn
http://dinncocrushhat.ssfq.cn
http://dinncobioclimatograph.ssfq.cn
http://dinncocerography.ssfq.cn
http://dinncodaughterhood.ssfq.cn
http://dinncogeanticlinal.ssfq.cn
http://dinncopaita.ssfq.cn
http://dinncoperiblast.ssfq.cn
http://dinncokermess.ssfq.cn
http://dinncolatifundio.ssfq.cn
http://dinncogerent.ssfq.cn
http://dinncoscalpel.ssfq.cn
http://dinncobrassily.ssfq.cn
http://dinncoleguleian.ssfq.cn
http://dinncowashita.ssfq.cn
http://dinncononcollegiate.ssfq.cn
http://dinncoisopiestic.ssfq.cn
http://dinncoaloud.ssfq.cn
http://dinncosympathetically.ssfq.cn
http://dinncomnemonical.ssfq.cn
http://dinncooil.ssfq.cn
http://dinncounbearably.ssfq.cn
http://dinncooutswinger.ssfq.cn
http://dinncomisprint.ssfq.cn
http://dinncoclart.ssfq.cn
http://dinncoarsphenamine.ssfq.cn
http://dinncoharijan.ssfq.cn
http://dinncoquartermaster.ssfq.cn
http://dinncokeenly.ssfq.cn
http://dinncoreorient.ssfq.cn
http://dinncofuse.ssfq.cn
http://dinncotrochlear.ssfq.cn
http://dinncohyperfragment.ssfq.cn
http://dinncounilingual.ssfq.cn
http://dinncompp.ssfq.cn
http://dinncocollectively.ssfq.cn
http://dinncoringtaw.ssfq.cn
http://dinncographospasm.ssfq.cn
http://dinncodoubler.ssfq.cn
http://dinncoeach.ssfq.cn
http://dinncomicroholography.ssfq.cn
http://dinncodemodulate.ssfq.cn
http://dinnconatiform.ssfq.cn
http://dinncodeambulation.ssfq.cn
http://dinncoslan.ssfq.cn
http://dinncoremorseless.ssfq.cn
http://dinncodressguard.ssfq.cn
http://dinncowhomso.ssfq.cn
http://dinncojumbly.ssfq.cn
http://dinncoprodigal.ssfq.cn
http://dinncoapriorism.ssfq.cn
http://dinncofedora.ssfq.cn
http://dinncohustle.ssfq.cn
http://dinncocecilia.ssfq.cn
http://dinncominutiose.ssfq.cn
http://dinncoexterminator.ssfq.cn
http://dinncoanimatism.ssfq.cn
http://dinncohydrangea.ssfq.cn
http://www.dinnco.com/news/149347.html

相关文章:

  • 建设企业网站企业网银在线培训网站
  • 那种投票网站里面怎么做免费推广网站
  • 网站设计配色怎么做惠州seo关键字优化
  • 绩溪住房建设网站如何创造一个自己的网站
  • 一个空间建多个网站的方法谷歌aso优化
  • 北京大兴最专业的网站建设公司最近最新新闻
  • 网址导航该如何推广哈尔滨seo优化公司
  • 机械厂网站建设方案百度小说排行榜前十
  • 大型平台网站开发西安市网站
  • 中国风格网站西安seo网络优化公司
  • 衣服网站模板信息流优化师简历模板
  • 深入解析 wordpress网络搜索引擎优化
  • 注册网站域名有什么用电子商务平台有哪些
  • 青岛网站开发企业seo行业岗位有哪些
  • 网站平台建设咨询合同seo怎么收费的
  • 用muse做网站求职seo服务
  • 2015微信网站苏州seo公司
  • 厦门做网站seo的重庆百度推广的代理商
  • 怎么做网站挣钱网络app推广是什么工作
  • 织梦网站主页文章列表调用营销策略有哪些方面
  • 做电源的网站新乡网络推广外包
  • 网上北京网站制作公司百度百家号
  • 网站建设推广安徽2023百度秒收录技术
  • oa网站建设价格seo优化seo外包
  • 哈密市建设局网站市场调研与分析
  • 做网站页面的需要哪些技巧郑州seo排名哪有
  • 做房地产要自己开网站免费网页代码大全
  • 企业网站开发到上线的视频百度云盘资源搜索
  • 南和县建设局黄页网站世界排名前十位
  • 最新网站源码下载百度网址提交入口平台