如何扩展WF4属性窗格属性网格

技术如何进行WF4属性窗格PropertyGrid扩展今天就跟大家聊聊有关如何进行WF4属性窗格PropertyGrid扩展,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有

今天跟大家聊聊WF4 PropertyGrid如何扩展,可能很多人都不太懂。为了让大家更好的了解,边肖为大家总结了以下内容,希望大家能从这篇文章中有所收获。

1.我们有一个如下的CaryActivity活动:

namespacrypropertygridexten { public sealed classcaractivity : codeactivity { public inargumenttext { get;设置;} public double repeattcount { get;设置;} publicstringFileName { get设置;} protectedveridevidexecute(codeActivityContextContext){ } } } 2。上述活动中有重复计数和文件名属性。我们将在属性窗格中为这两个属性的设置自定义属性值编辑器。效果如下:

如何进行WF4属性窗格PropertyGrid扩展

3.定义分别对应两个属性的属性值编辑器,如下所示:

namespacrypropertygridexten { classcustominlinneeditor : propertyvalueeditor }

public海关

{

this。InlineEditorTemplatenbsp

;= new DataTemplate();   

  •             FrameworkElementFactory stack = new FrameworkElementFactory(typeof(StackPanel));  

  •             FrameworkElementFactory slider = new FrameworkElementFactory(typeof(Slider));  

  •             Binding sliderBinding = new Binding("Value");  

  •             sliderBinding.Mode = BindingMode.TwoWay;  

  •             slider.SetValue(Slider.MinimumProperty, 0.0);  

  •             slider.SetValue(Slider.MaximumProperty, 100.0);  

  •             slider.SetValue(Slider.ValueProperty, sliderBinding);  

  •             stack.AppendChild(slider);  

  •             FrameworkElementFactory textb = new FrameworkElementFactory(typeof(TextBox));  

  •             Binding textBinding = new Binding("Value");  

  •             textb.SetValue(TextBox.TextProperty, textBinding);  

  •             textb.SetValue(TextBox.IsEnabledProperty, false);  

  •             stack.AppendChild(textb);  

  •             this.InlineEditorTemplate.VisualTree = stack;  

  •         }  

  •     }  

  • }  

  • namespace CaryPropertyGridExten  

  • {  

  •     class FilePickerEditor : DialogPropertyValueEditor  

  •     {  

  •         public FilePickerEditor()  

  •         {  

  •             this.InlineEditorTemplate = new DataTemplate();   

  •             FrameworkElementFactory stack = new FrameworkElementFactory(typeof(StackPanel));  

  •             stack.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);  

  •             FrameworkElementFactory label = new FrameworkElementFactory(typeof(Label));  

  •             Binding labelBinding = new Binding("Value");  

  •             label.SetValue(Label.ContentProperty, labelBinding);  

  •             label.SetValue(Label.MaxWidthProperty, 90.0);  

  •             stack.AppendChild(label);  

  •             FrameworkElementFactory editModeSwitch = new FrameworkElementFactory(typeof(EditModeSwitchButton));  

  •             editModeSwitch.SetValue(EditModeSwitchButton.TargetEditModeProperty, PropertyContainerEditMode.Dialog);  

  •             stack.AppendChild(editModeSwitch);  

  •             this.InlineEditorTemplate.VisualTree = stack;  

  •         }  

  •         public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)  

  •         {  

  •             Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();  

  •             if (ofd.ShowDialog() == true)  

  •             {  

  •                 propertyValue.Value = ofd.FileName.Substring(ofd.FileName.LastIndexOf('\\') + 1);  

  •             }  

  •         }  

  •     }  

  • }  

  • 4.       在CaryActivity的构造函数中增加自定义属性的信息如下,关于AttributeTableBuilder及MetadataStore的使用可参考关于元数据存储区MetadateStore及AttributeTableBuilder这篇文章。

    public CaryActivity()        {            AttributeTableBuilder builder = new AttributeTableBuilder();

  •           builder.AddCustomAttributes(typeof(CaryActivity), "RepeatCount"new EditorAttribute(typeof(CustomInlineEditor), typeof(PropertyValueEditor)));  

  •           builder.AddCustomAttributes(typeof(CaryActivity), "FileName"new EditorAttribute(typeof(FilePickerEditor), typeof(DialogPropertyValueEditor)));  

  •           MetadataStore.AddAttributeTable(builder.CreateTable());  

  •       }    

  • 看完上述内容,你们对如何进行WF4属性窗格PropertyGrid扩展有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。

    内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/152042.html

    (2)

    相关推荐

    • Python解释器种类以及特点是什么

      技术Python解释器种类以及特点是什么这篇文章将为大家详细讲解有关Python解释器种类以及特点是什么,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。python解释器是

      攻略 2021年12月4日
    • python中fabric模块安装报错(pythonfabric怎么使用)

      技术python中Fabric模块怎么用这篇文章给大家分享的是有关python中Fabric模块怎么用的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。基础一:#!/usr/bin/env pyt

      攻略 2021年12月25日
    • 改脸型,大家对改脸型的方法了解多少

      技术改脸型,大家对改脸型的方法了解多少东方人向来崇尚瓜子小脸改脸型,所以瘦脸风大行其道。脸部宽大的原因包括脂肪因素、肌肉因素和骨骼因素。因此,针对上述原因采取不同的瘦脸方法,才能有更好的效果。下面就为大家科普一下常见的改

      生活 2021年10月21日
    • 查看docker容器停止原因(docker容器网络异常怎么办)

      技术docker容器时区错误问题该怎么解决docker容器时区错误问题该怎么解决,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。背景利用node-schedu

      攻略 2021年12月13日
    • 日历工具BusyCal mac版减速了该怎么解决

      技术日历工具BusyCal mac版减速了该怎么解决今天就跟大家聊聊有关日历工具BusyCal mac版减速了该怎么解决,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收

      攻略 2021年12月8日
    • ADO.NET框架是什么

      技术ADO.NET框架是什么这篇文章主要介绍“ADO.NET框架是什么”,在日常操作中,相信很多人在ADO.NET框架是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”ADO.NET框架

      攻略 2021年12月3日