Tuesday, May 8, 2012

How to enable/disable a Button depending on the selection's type in WPF?

I want to trigger a button's enabled state, according to the type of the current selection.



E.g. I have a treeview that displayes parents and their children. If the selection is on a 'parent' item, the button 'btnShowParentData' is enabled.
I've done this via ValueConvertion:



<Button name="btnShowParentData" IsEnabled="{Binding ElementName=tree, Path=SelectedValue, Converter={StaticResource ParentSelectedConv}}" />


I look for a more elegant way. I don't want to create a ConverterClass for each selection type.





No comments:

Post a Comment