PropertyValueEditor with Slider

Here, we will create a new PropertyValueEditor, which will allow us to slide the slider to chnage the property value. If your property is a double type with specified minimum and maximum boundaries, we can use the slider propertyvalueeditor for easy access of the property.

In my custom activity, I have the RepeatCount property, where I used the Slider Property Value Editor.

 Bound the PropertyValueEditor to the Property

[Editor(typeof(PropertyEditors.CustomSliderPropertyValueEditor), typeof(ExtendedPropertyValueEditor))]

public double RepeatCount { get; set; }

 Custom Slider PropertyValueEditor Code:

 

public class CustomSliderPropertyValueEditor: PropertyValueEditor

{

 

public CustomSliderPropertyValueEditor() (); 

{DataTemplate customTemplate= 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 = customTemplate;  

this .InlineEditorTemplate.VisualTree = stack; }

}





Advertisements

About ambilykk

I am a Technology Evangelist on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Azure and Visual Studio. Technology adoption and learning is my key strength and technology sharing is my passion.
This entry was posted in WF, WF4 and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s