I have several ComboBoxes in a DataForm and am trying to have it so that certain ComboBoxes are disabled until a particular ComboBox is selected. To this end, I created a notification property named CanEditCombo
in the class that is bound to the DataContext and configured my ComboBoxes like so:
<ComboBox ... IsEnabled="{Binding CanEditCombo, Mode=OneWay}" />
The CanEditCombo
is initially false, yet my ComboBoxes are editable when the DataForm first loads.
If I apply the same IsEnabled
binding syntax to a TextBox in my DataForm it works as expected: disabled at first but enabled once CanEditCombo
becomes true.
Here is an example chunk of XAML:
<toolkit:DataForm CurrentItem="{Binding NewProject, Mode=TwoWay}" x:Name="dfNewProject" CommandButtonsVisibility="None">
<toolkit:DataForm.EditTemplate>
<DataTemplate>
<StackPanel>
...
<toolkit:DataField>
<ComboBox ItemsSource="{Binding ProjectOptions, Mode=OneWay}"
SelectedValue="{Binding Options, Mode=TwoWay}"
DisplayMemberPath="Value"
SelectedValuePath="Key"
IsEnabled="{Binding CanEditCombo, Mode=OneWay}" />
</toolkit:DataField>
...
</StackPanel>
</DataTemplate>
</toolkit:DataForm.EditTemplate>
</toolkit:DataForm>
What's more, even if I hard-code the ComboBox's IsEnabled
property to False in the markup above the ComboBox is still editable.
How do I go about having the ComboBox's IsEnable
property set via binding syntax when the ComboBox is in a DataForm?