成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

淺析WF4屬性窗格PropertyGrid擴展

開發 后端
我們將討論的是WF4屬性窗格PropertyGrid擴展,Windows Workflow Foundation(WF),WF是一個通用的編程框架,它可用于創建需要對外部實體的信號作出響應的交互式程序。

本文將講解的是WF4屬性窗格PropertyGrid擴展,希望對大家了解Windows Workflow Foundation框架有所幫助。

#T#

1.       我們有一個CaryActivity活動如下:

  1. namespace CaryPropertyGridExten  
  2. {  
  3.     public sealed class CaryActivity : CodeActivity  
  4.     {          
  5.         public InArgument Text { getset; }  
  6.         public double RepeatCount { getset; }  
  7.        public string FileName { getset; }             
  8.         protected override void Execute(CodeActivityContext context)  
  9.         {                         
  10.         }  
  11.     }  

2.       上面活動有RepeatCount和FileName屬性,我們會為這兩個屬性在屬性窗格的設置自定義屬性值編輯器,要達到效果如下圖:

效果圖

3.       分別定義兩個屬性對應的屬性值編輯器如下:

  1. namespace CaryPropertyGridExten  
  2. {  
  3.     class CustomInlineEditor : PropertyValueEditor  
  4.     {   
  5.         public CustomInlineEditor()  
  6.         {  
  7.             this.InlineEditorTemplate = new DataTemplate();   
  8.             FrameworkElementFactory stack = new FrameworkElementFactory(typeof(StackPanel));  
  9.             FrameworkElementFactory slider = new FrameworkElementFactory(typeof(Slider));  
  10.             Binding sliderBinding = new Binding("Value");  
  11.             sliderBinding.Mode = BindingMode.TwoWay;  
  12.             slider.SetValue(Slider.MinimumProperty, 0.0);  
  13.             slider.SetValue(Slider.MaximumProperty, 100.0);  
  14.             slider.SetValue(Slider.ValueProperty, sliderBinding);  
  15.             stack.AppendChild(slider);  
  16.             FrameworkElementFactory textb = new FrameworkElementFactory(typeof(TextBox));  
  17.             Binding textBinding = new Binding("Value");  
  18.             textb.SetValue(TextBox.TextProperty, textBinding);  
  19.             textb.SetValue(TextBox.IsEnabledProperty, false);  
  20.             stack.AppendChild(textb);  
  21.             this.InlineEditorTemplate.VisualTree = stack;  
  22.         }  
  23.     }  
  24. }  
  25. namespace CaryPropertyGridExten  
  26. {  
  27.     class FilePickerEditor : DialogPropertyValueEditor  
  28.     {  
  29.         public FilePickerEditor()  
  30.         {  
  31.             this.InlineEditorTemplate = new DataTemplate();   
  32.             FrameworkElementFactory stack = new FrameworkElementFactory(typeof(StackPanel));  
  33.             stack.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);  
  34.             FrameworkElementFactory label = new FrameworkElementFactory(typeof(Label));  
  35.             Binding labelBinding = new Binding("Value");  
  36.             label.SetValue(Label.ContentProperty, labelBinding);  
  37.             label.SetValue(Label.MaxWidthProperty, 90.0);  
  38.             stack.AppendChild(label);  
  39.             FrameworkElementFactory editModeSwitch = new FrameworkElementFactory(typeof(EditModeSwitchButton));  
  40.             editModeSwitch.SetValue(EditModeSwitchButton.TargetEditModeProperty, PropertyContainerEditMode.Dialog);  
  41.             stack.AppendChild(editModeSwitch);  
  42.             this.InlineEditorTemplate.VisualTree = stack;  
  43.         }  
  44.         public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)  
  45.         {  
  46.             Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();  
  47.             if (ofd.ShowDialog() == true)  
  48.             {  
  49.                 propertyValue.Value = ofd.FileName.Substring(ofd.FileName.LastIndexOf('\\') + 1);  
  50.             }  
  51.         }  
  52.     }  
  53. }  

4.       在CaryActivity的構造函數中增加自定義屬性的信息如下,關于AttributeTableBuilder及MetadataStore的使用可參考關于元數據存儲區MetadateStore及AttributeTableBuilder這篇文章。

  1. public CaryActivity()  
  2.       {  
  3.           AttributeTableBuilder builder = new AttributeTableBuilder();  
  4.           builder.AddCustomAttributes(typeof(CaryActivity), "RepeatCount"new EditorAttribute(typeof(CustomInlineEditor), typeof(PropertyValueEditor)));  
  5.           builder.AddCustomAttributes(typeof(CaryActivity), "FileName"new EditorAttribute(typeof(FilePickerEditor), typeof(DialogPropertyValueEditor)));  
  6.           MetadataStore.AddAttributeTable(builder.CreateTable());  
  7.       }    

原文標題:WF4:屬性窗格PropertyGrid擴展

鏈接:http://www.cnblogs.com/carysun/archive/2009/11/30/WF4-PropertyGridExten.html

責任編輯:彭凡 來源: 博客園
相關推薦

2009-10-22 08:54:56

WF4 Beta 2

2009-10-30 09:04:18

WF4 Beta2

2009-08-10 17:36:17

C#擴展方法

2011-12-01 15:51:35

JavaJavaFX

2011-06-13 11:07:22

QT 移植

2009-08-21 15:57:58

C# DataSour

2009-07-17 17:05:44

iBATIS緩存cacheModel

2022-01-18 09:46:37

鴻蒙HarmonyOS應用

2009-08-28 14:25:57

C# byte數組

2011-12-26 10:49:27

JavaJUnitRunner

2009-12-28 14:40:08

WPF屬性

2009-07-29 09:34:54

IsPostBack屬ASP.NET

2010-08-24 13:14:36

CSSmargin

2009-09-03 17:18:40

C#擴展性對象模型

2010-03-30 08:40:36

WCF

2009-09-07 04:56:52

C#模式窗體

2009-03-17 16:18:51

JspActionStruts

2019-08-23 11:31:41

WindowsWindows 10軟件

2009-11-26 13:12:16

Silverlight

2009-08-24 16:39:19

C# 泛型應用
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 最新国产精品精品视频 | 日韩欧美不卡 | 天天操妹子 | 国产一区91精品张津瑜 | 欧美a在线看 | 九九免费 | 韩日一区二区 | 国产91久久精品一区二区 | 91在线一区 | 国产精品高清在线 | 天堂在线网 | 亚洲三区在线观看 | 久久机热 | 亚洲视频免费 | 久久久久久看片 | 91佛爷在线观看 | 国产探花在线精品一区二区 | 精品粉嫩超白一线天av | 欧美一级在线视频 | 精品一级电影 | 久久黄视频 | 精品国产18久久久久久二百 | 亚洲成人在线免费 | 国产欧美在线 | 欧美一级大黄 | 99免费在线视频 | 欧美国产一区二区三区 | 日韩在线免费视频 | 日韩精品成人免费观看视频 | 成人午夜精品 | 国家一级黄色片 | 成人黄色电影在线播放 | 久久久精品一区二区 | 狠狠亚洲| 国产亚洲区| 先锋资源亚洲 | 精品久久久一区 | 国产精品久久 | 精品日韩一区二区 | 中文字幕在线免费 | 天天操网|