日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
淺析WF4屬性窗格PropertyGrid擴(kuò)展

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

十余年的泰山網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整泰山建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)公司從事“泰山網(wǎng)站設(shè)計”,“泰山網(wǎng)站推廣”以來,每個客戶項目都認(rèn)真落實執(zhí)行。

#T#

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

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

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

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

  
  
  
  
  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的構(gòu)造函數(shù)中增加自定義屬性的信息如下,關(guān)于AttributeTableBuilder及MetadataStore的使用可參考關(guān)于元數(shù)據(jù)存儲區(qū)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.       }    

新聞標(biāo)題:淺析WF4屬性窗格PropertyGrid擴(kuò)展
新聞來源:http://www.dlmjj.cn/article/ccsjojh.html