In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to expand the WF4 property pane PropertyGrid. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
1. We have a CaryActivity activity as follows:
Namespace CaryPropertyGridExten {public sealed class CaryActivity: CodeActivity {public InArgument Text {get; set;} public double RepeatCount {get; set;} public string FileName {get; set;} protected override void Execute (CodeActivityContext context) {}
two。 The above activities have RepeatCount and FileName attributes. We will set a custom attribute value editor for these two properties in the properties pane, as shown below:
3. The attribute value editors that define the two attributes are as follows:
Namespace CaryPropertyGridExten {class CustomInlineEditor: PropertyValueEditor
{
Public CustomInlineEditor ()
{
This.InlineEditorTemplate = 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. The information to add custom attributes to the constructor of CaryActivity is as follows. For more information on the use of AttributeTableBuilder and MetadataStore, please refer to this article on metadata stores MetadateStore and 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 ())
}
After reading the above, do you have any further understanding of how to extend the WF4 property pane PropertyGrid? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.