How to enable/disable a Button depending on the selection's type in WPF?
Domanda
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.
Soluzione
I don't want to create a ConverterClass for each selection type.
You can have properties on the converter to parameterize it.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow