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

长治市城乡建设局网站淘宝做网站的都是模板

长治市城乡建设局网站,淘宝做网站的都是模板,网站广告设计怎么做,怎么做出有品牌感的网站第一步#xff1a;自定义控件的TypeDescription描述。 为了扩展.NET的类型描述系统(Type Descriptor System)#xff0c;在运行时动态地更改对象的属性#xff0c;使得这些属性在PropertyGrid上下文中不会被显示。 1.CLTypeDescriptionProvider#xff1a;这是一个TypeDesc… 第一步自定义控件的TypeDescription描述。 为了扩展.NET的类型描述系统(Type Descriptor System)在运行时动态地更改对象的属性使得这些属性在PropertyGrid上下文中不会被显示。 1.CLTypeDescriptionProvider这是一个TypeDescriptionProvider的实现。TypeDescriptionProvider是.NET的一部分用于提供有关类型的信息。在这个实现中它将返回一个自定义的ICustomTypeDescriptor实现即CLTypeDescriptor。 2.CLTypeDescriptor这是一个ICustomTypeDescriptor的实现。ICustomTypeDescriptor为对象提供了一种方式来提供有关其属性的自定义信息。在这个实现中它将返回一个包含自定义PropertyDescriptor的PropertyDescriptorCollection。 3.CLPropertyDescriptor这是一个PropertyDescriptor的实现。PropertyDescriptor描述了一个对象的属性包括其名称、类型、默认值等。在这个实现中它将返回一个修改过的AttributeCollection该AttributeCollection包含一个新的BrowsableAttribute其值为false。这意味着这个属性在PropertyGrid上下文中不会被显示。 这是代码 public class CLTypeDescriptionProvider : TypeDescriptionProvider {public CLTypeDescriptionProvider(): base(TypeDescriptor.GetProvider(typeof(object))) { }public override ICustomTypeDescriptor GetTypeDescriptor(Type type, object o){ICustomTypeDescriptor baseDescriptor base.GetTypeDescriptor(type, o);return new CLTypeDescriptor(baseDescriptor);} }public class CLTypeDescriptor : CustomTypeDescriptor {ICustomTypeDescriptor original;public CLTypeDescriptor(ICustomTypeDescriptor originalDescriptor): base(originalDescriptor) { original originalDescriptor; }public override PropertyDescriptorCollection GetProperties(){ return this.GetProperties(new Attribute[] { }); }public override PropertyDescriptorCollection GetProperties(Attribute[] attributes){var properties base.GetProperties(attributes).CastPropertyDescriptor().Select(p new CLPropertyDescriptor(p)).ToArray();return new PropertyDescriptorCollection(properties, true);} }public class CLPropertyDescriptor : PropertyDescriptor {PropertyDescriptor o;public CLPropertyDescriptor(PropertyDescriptor originalProperty): base(originalProperty) { o originalProperty; }public override bool CanResetValue(object component){ return o.CanResetValue(component); }public override object GetValue(object component) { return o.GetValue(component); }public override void ResetValue(object component) { o.ResetValue(component); }public override void SetValue(object component, object value){ o.SetValue(component, value); }public override bool ShouldSerializeValue(object component){ return o.ShouldSerializeValue(component); }public override AttributeCollection Attributes{get{var attributes base.Attributes.CastAttribute().ToList();var category attributes.OfTypeCategoryAttribute().FirstOrDefault();//if (category ! null category.Category Extra) attributes.Add(new BrowsableAttribute(true));attributes.Add(new BrowsableAttribute(false));return new AttributeCollection(attributes.ToArray());}}public override Type ComponentType { get { return o.ComponentType; } }public override bool IsReadOnly { get { return o.IsReadOnly; } }public override Type PropertyType { get { return o.PropertyType; } } } 第二步自定义控件注入类特性CLTypeDescriptionProvider字段特性Category、Browsable、DisplayName、Editor。 1.CategoryAttribute这个特性用于将属性分组到特定的类别中。在PropertyGrid控件中类似的属性可以被组织在一起。例如你可以使用[Category(Appearance)]来指示属性应该在Appearance类别下显示。 2.BrowsableAttribute这个特性用于控制属性是否应PropertyGrid控件中显示。如果你设置[Browsable(false)]该属性将不会在属性浏览器中显示。 3.DisplayNameAttribute这个特性用于控制属性在PropertyGrid控件中的显示名称。默认情况下属性的名称就是它在代码中的名称。但是你可以使用[DisplayName(My Property)]来改变它在属性浏览器中的显示名称。 4.EditorAttribute这个特性用于指定用于编辑属性的编辑器。这个编辑器可以是一个字符串编辑器也可以是一个复杂的用户界面。例如你可以使用[Editor(typeof(MyCustomEditor), typeof(UITypeEditor))]来指定一个自定义的编辑器。在这个例子中MyCustomEditor需要继承自UITypeEditor类它提供了创建和管理属性编辑器的方法。 这是代码 [TypeDescriptionProvider(typeof(CLTypeDescriptionProvider))]public class ClLabel : UserControl, IExecutable, ICommunicationBindable{ [Browsable(true)] [Category(自定义项目)] [DisplayName(VM项目)] [Editor(typeof(WpfApp2.OpenCollectionEditor), typeof(OpenCollectionView))] public CustomType VMItem {get { return (CustomType)GetValue(VMItemProperty); }set { SetValue(VMItemProperty, value); } } 第三步实现自定义编辑器该类继承自PropertyEditorBase。OpenCollectionEditor是一个自定义编辑器用于编辑属性。 OpenCollectionEditor类覆盖了PropertyEditorBase的两个方法CreateElement和GetDependencyProperty。 1.CreateElement方法接受一个PropertyItem参数该参数表示要编辑的属性。在此方法中你首先获取属性的值假设它是一个ClLabel类型的对象然后创建一个OpenCollectionView对象并将ClLabel对象的VMItem属性设置为OpenCollectionView的customType。然后你将VMItem对象序列化为JSON字符串并设置为OpenCollectionView的txt文本。最后你返回OpenCollectionView对象这个对象将用于编辑属性。 2.GetDependencyProperty方法返回一个DependencyProperty对象该对象表示OpenCollectionView的CustomTypeProperty。DependencyProperty是WPF中的一个重要概念它支持属性值的继承数据绑定等功能。 这是代码 public class OpenCollectionEditor : PropertyEditorBase{public override FrameworkElement CreateElement(PropertyItem propertyItem) {var model propertyItem.Value as ClLabel;OpenCollectionView openCollectionView new OpenCollectionView();openCollectionView.customType model.VMItem;openCollectionView.txt.TextJsonConvert.SerializeObject(model.VMItem);return openCollectionView;} public override DependencyProperty GetDependencyProperty() OpenCollectionView.CustomTypeProperty;} 第三步实现显示的自定义属性。 public partial class OpenCollectionView : UserControl{public OpenCollectionView(){InitializeComponent();DataContextChanged OpenCollectionView_DataContextChanged;}private void OpenCollectionView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e){RelayCommandCustomType cmd new RelayCommandCustomType(param {var editor new CustomControlWindow();editor.ShowDialog();return editor.selectedItem;});cmd.Executed result {txt.Text JsonConvert.SerializeObject(result);};btn.Command cmd;}public CustomType customType{get (CustomType)GetValue(CustomTypeProperty);set SetValue(CustomTypeProperty, value);}public static readonly DependencyProperty CustomTypeProperty DependencyProperty.Register(nameof(customType), typeof(CustomType), typeof(OpenCollectionView), new PropertyMetadata(default(CustomType)));public ICommand ServoOMCItemEditCommand { get; set; }}
http://www.yayakq.cn/news/2145/

相关文章:

  • 利用对象储存做网站ps网站页面设计教程
  • 做投资理财网站微信小程序怎么做网站
  • 免费做网站的软件宁波seo服务引流推广
  • 中装建设官方网站哪家做企业网站
  • 大气黑色女性时尚类网站织梦模板代码高亮wordpress
  • 怎么做网站的百度排名长沙河西网站建设
  • 上海专业微信网站开发公司公司网站用个人备案 2018
  • 东昌府网站建设公司域名分类网站
  • 深圳公司社保网站如何利用seo赚钱
  • 成都网站建设987net手机网页制作作品
  • 深圳建设工程交易中心网站营销网站建设公司地址
  • 网站开发样例衡水注册公司流程和费用
  • 石家庄网站建设服务群晖wordpress外网
  • 给传销产品做网站物业网站模板下载
  • 贵港公司做网站怎么做网站模块
  • 厦门网站制作哪里好薇企业所得税规避50种
  • icp网站负责人做海报的素材那个网站比较好
  • 网络营销课程有哪些湖南专业seo公司
  • 建设网站定位分析机械制造设备类企业网站织梦模板
  • 如何建立免费的个人企业网站建筑网站大全免费
  • 襄阳营销型网站建设秦皇岛做网站的公司
  • 网站服务器和空间大小1688首页
  • 淘宝店铺网站建设郑州公共住宅建设投资有限公司网站
  • 网站备案对应的ip地址短视频运营岗位职责和任职要求
  • 折扣网站模板外贸 静态网站 怎么做
  • 政协网站 是政协信息化建设域名备案需要有网站吗
  • 辽宁市营商环境建设局网站用ai怎么做网站
  • wordpress搬家后台还是老网站网络科技扣钱是咋回事
  • 怎么做自己优惠券网站vue适合什么网站开发
  • 猎头可以做单的网站wordpress 获取微博