I have a list a simple dialog box which contains a few checkboxes, I wanted to have an Ok button that would be disabled unless the user changed a setting. In my view I have an OkEnabled property that I was binding the isEnabled property of the button to, if a check box changes its value it sets OkEnabled to true, but for some reason this doesnt enable the button.
public bool OkEnabled
{
get
{
return m_okEnabled;
}
set
{
m_okEnabled = value;
OnPropertyChanged("OkEnabled");
}
}
<Button Content="OK" Style="{StaticResource MyButton}" Height="23"
HorizontalAlignment="Left" Margin="20" Name="m_okbutton"
VerticalAlignment="Top" Width="75"
Click="okClick" IsEnabled="{Binding Path=OkEnabled}"/>
For some reason the Ok button won’t change state when the OkEnabled property changes state. If I bind the IsEnabled property to one of the checkboxes I can see the button change state as the check box changes.
By default, bindings are relative to the DataContext, not the view. Did you set the view as its own DataContext ?