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

    相关推荐

    • Oracle内存结构面试题有哪些

      技术Oracle内存结构面试题有哪些这篇文章主要介绍“Oracle内存结构面试题有哪些”,在日常操作中,相信很多人在Oracle内存结构面试题有哪些问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家

      攻略 2021年11月5日
    • ES6新特性常用的知识点有哪些

      技术ES6新特性常用的知识点有哪些这篇文章主要介绍了ES6新特性常用的知识点有哪些,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。1.关键字Let 关键字

      攻略 2021年11月13日
    • 如何修改linux下mysql环境变量

      技术如何修改linux下mysql环境变量这篇文章主要介绍如何修改linux下mysql环境变量,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!找到linux下面mysql执行路径 eipdb2:~

      攻略 2021年10月29日
    • ambari禁用kerberos认证(ambari关闭kerberos认证)

      技术Ambari 开启kerberos报错add_principal:分析主体时主体的格式不正确怎么解决Ambari 开启kerberos报错add_principal:分析主体时主体的格式不正确怎么解决,很多新手对此不

      攻略 2021年12月23日
    • vue学习---列表过滤

      技术vue学习---列表过滤 vue学习---列表过滤!DOCTYPE html
      htmlheadmeta charset="UTF-8" /title列表过滤/titlescript type="te

      礼包 2021年11月14日
    • 喵喵喵是什么意思,猫往人身上蹭是什么意思

      技术喵喵喵是什么意思,猫往人身上蹭是什么意思猫咪蹭人可是有着很丰富的含义呢,各位铲屎官快点跟着喵大侠来了解一下吧喵喵喵是什么意思。1、如果猫咪用小脑袋的一侧、身体的一侧,或者是用尾巴对着你蹭来蹭去,这是给你打个招呼呢!一

      生活 2021年10月26日