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

建筑工程教育网官方网站视频制作教程自学

建筑工程教育网官方网站,视频制作教程自学,扶风做企业网站,免费注册qq号网站本文将详细讲述Silverlight中Binding#xff0c;包括Binding的属性和用法#xff0c;Binding的数据流向。 Binding:一个完整的Binding过程是让源对象中的某个属性值通过一定流向规则进行转换和验证之后绑定到目标对象的某个属性上面。这个源对象由ElementName指定#xff0c…        本文将详细讲述Silverlight中Binding包括Binding的属性和用法Binding的数据流向。         Binding:一个完整的Binding过程是让源对象中的某个属性值通过一定流向规则进行转换和验证之后绑定到目标对象的某个属性上面。这个源对象由ElementName指定源对象的属性由Path指定流向规则由Mode指定转换由Converter指定验证由ValidatesOnDataErrors等指定。         首先我们来看Binding的属性如下     ElementName:指定源对象的名称     Path:指定需要绑定的源对象的属性名称     Mode:指定Binding的数据流向规则     Converter:指定源对象的属性需要经过用户自定义的转换         其次我们来看看Binding的数据流向Mode分为以下几种     OneTime:源对象的属性只有在第一次的时候绑定到目标对象以后源对象属性值变化时目标对象值不变     OneWay:源对象的属性值变化的时候目标对象值也跟着相应变化而目标对象值变化时源对象属性值不变     TwoWay:源对象的属性值变化的时候目标对象值也跟着相应变化目标对象值变化时源对象属性值也跟着变          下面我们通过以下实例源码来看看Binding的简单应用和转换注意Mode为TwoWay的时候目标对象更新时需要转移焦点(LostFocus)才触发更新源对象。例如本文实例中需要点击到另外的TextBox才更新源。 Xaml UserControl x:ClassSLBinding.MainPage xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:xhttp://schemas.microsoft.com/winfx/2006/xaml xmlns:dhttp://schemas.microsoft.com/expression/blend/2008 xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:localclr-namespace:SLBinding mc:Ignorabled d:DesignHeight600 d:DesignWidth800 xmlns:sdkhttp://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk UserControl.Resources local:ImageConverter x:KeyImageCoverter/ /UserControl.Resources Grid x:NameLayoutRoot BackgroundWhite !--One Time-- StackPanel OrientationHorizontal sdk:Label Height28 HorizontalAlignmentLeft Margin130,56,0,0 Namelabel1 VerticalAlignmentTop Width120 ContentOne Time: / TextBox Height23 HorizontalAlignmentLeft Margin20,56,0,0 NametbOneTimeSource VerticalAlignmentTop Width120 Text初次绑定 / TextBox Height23 HorizontalAlignmentLeft Margin20,56,0,0 NametbOneTimeTarget VerticalAlignmentTop Width120 Text{Binding ElementNametbOneTimeSource, PathText, ModeOneTime}/ /StackPanel !--One Way-- StackPanel OrientationHorizontal sdk:Label Height28 HorizontalAlignmentLeft Margin130,100,0,0 Namelabel2 VerticalAlignmentTop Width120 ContentOne Way: / TextBox Height23 HorizontalAlignmentLeft Margin20,100,0,0 NametbOneWaySource VerticalAlignmentTop Width120 Text单向绑定 / TextBox Height23 HorizontalAlignmentLeft Margin20,100,0,0 NametbOneWayTarget VerticalAlignmentTop Width120 Text{Binding ElementNametbOneWaySource, PathText, ModeOneWay}/ /StackPanel !--Two Way-- StackPanel OrientationHorizontal sdk:Label Height28 HorizontalAlignmentLeft Margin130,150,0,0 Namelabel3 VerticalAlignmentTop Width120 ContentOne Time: / TextBox Height23 HorizontalAlignmentLeft Margin20,150,0,0 NametbTwoWaySource VerticalAlignmentTop Width120 Text双向绑定 / TextBox Height23 HorizontalAlignmentLeft Margin20,150,0,0 NametbTwoWayTarget VerticalAlignmentTop Width120 Text{Binding ElementNametbTwoWaySource, PathText, ModeTwoWay}/ /StackPanel !--Converter-- StackPanel OrientationHorizontal sdk:Label Height28 HorizontalAlignmentLeft Margin130,220,0,0 Namelabel5 VerticalAlignmentTop Content下面将网络图片地址使用Converter自动绑定转换为图片显示出来 / /StackPanel StackPanel OrientationHorizontal sdk:Label Height28 HorizontalAlignmentLeft Margin130,250,0,0 Namelabel4 VerticalAlignmentTop Width120 ContentConverter: / TextBox Height23 HorizontalAlignmentLeft Margin20,250,0,0 NametbConverter VerticalAlignmentTop Texthttp://sc.admin5.com/uploads/allimg/100211/105R33342-7.png / Image NameimgCity Width60 Height60 Source{Binding ElementNametbConverter,PathText, ModeTwoWay, Converter{StaticResource ImageCoverter}}/Image /StackPanel /Grid/UserControl   ImageConverter.cs public class ImageConverter : IValueConverter {//在载入数据的时候将数据转换为图片类型 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {try { Uri uri new Uri((string)value, UriKind.RelativeOrAbsolute); BitmapImage img new BitmapImage(uri);return img; }catch {return new BitmapImage(); } }//在页面上操作的时候将图片类型转换为数据这里只有再TwoWay的时候才有用 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { BitmapImage img value as BitmapImage;return img.UriSource.AbsoluteUri; } }         下面我们来看看本实例运行效果如下图如需源码请点击 SLBinding.zip 下载
http://www.zqtcl.cn/news/330981/

相关文章:

  • 网站制作电话多少网站商品图片怎么做
  • 定制做网站平台网站什么情况要更新
  • 上海网站建设哪家国外有哪些网站可以做电商
  • 网络软文推广网站wordpress仿站抓取软件
  • 安徽圣力建设集团网站当当网站建设与易趣网站对比
  • 长沙网站设计制作DW做注册网站
  • 商城设计网站关键词的优化在哪做
  • 网站锚文本网络营销的解释
  • 苏州专业网站建设网站模板是什么
  • 科技网站设计案例百度收录情况查询
  • gif放网站有锯齿策划公司宣传语
  • 淘宝客做网站怎样推广空间购买后打不开网站
  • 信阳网站设计银川网站建设nx110
  • 建设安全协会网站58招聘运营网站怎么做
  • 做原创的网站做游戏平面设计好的素材网站有哪些
  • 校园网站wordpress 防攻击插件
  • wordpress 更好的主题丁的老头seo博客
  • 上海市工程信息网站北京专业网站翻译影音字幕翻译速记速记速记速而高效
  • 网站建设心得体会500字网页制作三剑客是指什么
  • 大连做网站优化一级a做爰片 网站就能看
  • 网站优化页面中山seo网络推广
  • 建设网站一定要数据库吗湖北百度seo
  • 下载了wordpress然后怎么用怎样健建设一个有利于优化的网站
  • 网站开发心得500字做代售机票网站程序
  • php电影网站开发凡诺网站建设
  • 兰州道路建设情况网站南宁网站开发
  • 网站开发服务费投资者网站建设
  • 网站开发 如何备案新站点seo联系方式
  • 自动全屏网站模板贵州网站制作公司电话
  • 南昌购物网站制作国外免费网站空间