here is my xaml:
<Button
x:Name="StartBtn"
Content="Start"
Command="{Binding StartProcess}"
HorizontalAlignment="Left"
Height="23"
Margin="241,181,0,0"
VerticalAlignment="Top"
Width="57"
Grid.Column="1"
IsEnabled="{Binding IsStartButtonEnabled}"/>
here is my property:
private bool _isStartButtonEnabled;
public bool IsStartButtonEnabled
{
get { return _isStartButtonEnabled; }
set
{
_isStartButtonEnabled = value;
OnPropertyChanged("IsStartButtonEnabled");
}
}
it works with whatever i set it to on startup, but when i manipulate the bool later in the code, the change is not reflected in the WPF. I do have the data context set correctly as other bindings all function perfectly.
Also when I manipulate the Bool in the code I am using the property and not the private field.
private void OnStartProcess()
{
IsStartButtonEnabled = false;
//stuff
}
答案 0 :(得分:0)
It is working, make sure you are setting the public property in your code and not the private field:
public RelayCommand StartProcess
{
get
{
return new RelayCommand(Execute);
}
}
private void Execute()
{
IsStartButtonEnabled = false;
}