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

网站开发直播软件软件定制开发公司

网站开发直播软件,软件定制开发公司,河南免费网站建设公司,网站建设哪种语言好文章目录 前言一、自定义控件部分二、在页面中使用总结 前言 在一个页面,重复用到同一个自定义控件时,该如何对控件分别进行数据绑定呢?这时候可以赋予控件一个自定义的属性,来完成此操作。 一、自定义控件部分 为自定以控件设置…

文章目录

  • 前言
  • 一、自定义控件部分
  • 二、在页面中使用
  • 总结

前言

在一个页面,重复用到同一个自定义控件时,该如何对控件分别进行数据绑定呢?这时候可以赋予控件一个自定义的属性,来完成此操作。


一、自定义控件部分

为自定以控件设置 DataTag和SelectedI属性。

<UserControl x:Class="Module3DS.Components.DataList"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Module3DS.Components"mc:Ignorable="d" d:DesignHeight="250" d:DesignWidth="300"><GroupBox Grid.Column="0" Header="数据列表"><DataGrid x:Name="PrjDg" HeadersVisibility="Column" SelectedIndex="{Binding SelectedI}" ItemsSource="{Binding}" Tag="{Binding DataTag}"  ScrollViewer.VerticalScrollBarVisibility="Visible"   CanUserAddRows="False" AutoGenerateColumns="False" CanUserSortColumns="False" MouseDoubleClick="PrjDg_MouseDoubleClick"><DataGrid.Columns><DataGridTextColumn Binding="{Binding NUM}"  Header="一" Width="1*"  IsReadOnly="True"/><DataGridTextColumn Binding="{Binding STAKEKM}" Header="二" IsReadOnly="True" Width="2*"/></DataGrid.Columns></DataGrid></GroupBox>
</UserControl>

控件后端:

   public partial class DataList : UserControl{public DataList(){InitializeComponent();//BingdingFun("TagData", DataGrid.TagProperty);BingdingFun("SelectedI", DataGrid.SelectedIndexProperty);}private void BingdingFun(string name,DependencyProperty dp) {Binding bing = new Binding(name);bing.Source = this;bing.Mode = BindingMode.TwoWay;BindingOperations.SetBinding(PrjDg, dp, bing);}public static readonly DependencyProperty ISProperty = DependencyProperty.Register("TagData", typeof(Object), typeof(DataList));public static readonly DependencyProperty SIProperty = DependencyProperty.Register("SelectedI", typeof(int), typeof(DataList));public Object DataTag{get { return (Object)GetValue(ISProperty); }set { SetValue(ISProperty, value); }}public int SelectedI { get { return (int)GetValue(SIProperty); }set { SetValue(SIProperty, value); }}
}      

二、在页面中使用

<Components:DataList Grid.Column="0" x:Name="Data3DList" DataTag="Data3D" />
<Components:DataList x:Name="IndexDataList" DataTag="DataIndex" />

如此一来,我们的控件就有了DataTag和SelectedI属性,如果你使用的MVVM,还可以做到如下这样

<Components:DataList x:Name="IndexDataList" DataTag="{Binding 属性}" SelectedI= "{Binding 属性}"/>

总结

以上就是如何为自定义控件添加自定义属性了,我们下次再见,拜拜。

http://www.dtcms.com/wzjs/393034.html

相关文章:

  • 北京工程工程建设交易信息网站百度网盘在线登录
  • 台州高端网站建设网络媒体推广报价
  • 站长工具排名查询seo外链增加
  • 专做logo网站叫什么google关键词
  • 黑苹果做网站开发吗联盟营销平台
  • 网站程序设计安徽网站设计
  • 没有公司做网站影视站seo教程
  • windows和linux 做网站站长工具seo综合查询问题
  • 企业网站 三合一互联网公司排名
  • 做网站怎么买域名关键词一般是指什么
  • 深圳网站建设外包公司网上营销新观察网
  • 做中文的云图网站如何做好市场推广
  • 龙华做棋牌网站建设哪家公司便宜合肥网站优化技术
  • 门户 网站开发周期新闻 近期大事件
  • 网站建设公司网站定制开发如何去推广自己的产品
  • 用云怎么做网站社群营销的方法和技巧
  • 广州网站的优化北京网站快速优化排名
  • 南京seo排名外包郑州seo排名优化
  • 久产久人力有限公司郑州官网网站推广优化公司
  • 安庆做网站谷歌seo推广
  • dw网站制作流程seo关键词怎么优化
  • flash型网站凌哥seo技术博客
  • 宽屏网站js谷歌浏览器app
  • 上海营销型网站seo系统优化软件有哪些
  • 黑龙江最新疫情公布重庆seo技术博客
  • 与传统市场营销的区别与联系有哪些seo哪家好
  • 免费企业网站源代码四川企业seo推广
  • 网站推广工具大全成都网络优化公司有哪些
  • 做网站设计网站建设推广百度竞价排名事件
  • 怎么做化妆品网站内容规划seoshanghai net