如何扩展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)

    相关推荐

    • 如何深入分析Tomcat的Manager

      技术如何深入分析Tomcat的Manager如何深入分析Tomcat的Manager,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。关心Tom

      攻略 2021年12月8日
    • 速度单位换算,路程,速度,时间的关系式是什么

      技术速度单位换算,路程,速度,时间的关系式是什么路程速度单位换算,速度,时间的关系式是速度=路程/时间。科学上用速度来表示物体运动的快慢。速度在数值上等于单位时间内通过的路程。速度的计算公式:V=S/t。速度的单位是m/

      生活 2021年10月30日
    • js中判断字符串时间类型大小(js中如何判断时间大小写)

      技术怎样用JS判断日期数字整数和特殊字符怎样用JS判断日期数字整数和特殊字符,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。如何在用一个程序检测所输入的内

      攻略 2021年12月14日
    • 弹簧的劲度系数,弹簧被截断后的劲度系数

      技术弹簧的劲度系数,弹簧被截断后的劲度系数当然会变弹簧的劲度系数!以截一半为例,设原来劲度系数为k
      如果把两个部分首尾相连(串联)再在下面一个的末端挂上质量为m的物体,那么两弹簧总伸长是mg/k,因此每个部分伸长mg/2

      生活 2021年10月28日
    • mysql视图产生派生表无法优化案例

      技术mysql视图产生派生表无法优化案例 mysql视图产生派生表无法优化案例环境:mysql 5.7/8.0
      导入测试数据:git clone https://github.com/datacharm

      礼包 2021年11月4日
    • 如何进行JS中的事件冒泡与捕获

      技术如何进行JS中的事件冒泡与捕获这期内容当中小编将会给大家带来有关如何进行JS中的事件冒泡与捕获,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。刚接触 JS 的那个时候,啥也不懂,只想

      攻略 2021年11月16日