Condividi tramite


Binding activity properties to a custom control

Today, for a re-hosted application, generally users have the Designer, Toolbox and the Property Grid. The property grid provided has been hooked up pretty well with the designer. Thus any changes to the properties of an activity on the designer surface are bound pretty tightly with the property grid properties.

However, what if you have your custom control and you want to bind the changes on the designer surface with that specific custom control.

For example, you have a WPF Textbox in your application and you want to bind the changes to the ‘DisplayName’ property of your selected activity with this ‘Textbox.TextProperty’.

Solution:

 this.wd.Context.Items.Subscribe<Selection>(delegate(Selection selection)
{
       Binding myBinding = new Binding();
        myBinding.Path = new PropertyPath("DisplayName");
        myBinding.Source = selection.PrimarySelection;
        myTextBox.SetBinding(TextBox.TextProperty, myBinding);

});
  

Hope this helps!

Thanks,

Kushal.