I have a user window with 3 controls - an 'execute' button, a results control, and a processing control. My goal is to display the processing control after execute is pressed, then hide it when the execute method finishes.
However, the processing control does not display when I assumed it would... instead it only displays when (if) a callback function that creates another window prompting for user input is called.
The processing control has its visibility bound to a bool Processing
in my viewmodel via BoolToVis converter. The execute method sets Processing
to true at the start, then to false when it finishes. The setter of Processing
calls OnPropertyChanged.
My view model implements INotifyPropertyChanged.
private bool _processing;
public bool Processing
{
get
{ return _processing; }
set
{
_processing = value;
this.OnPropertyChanged("Processing");
}
}
private RelayCommand _search;
public RelayCommand Search
{
get { return _search ?? (_search = new RelayCommand(p => OnSearch(), p => CanSearch())); }
}
private void OnSearch()
{
this.Processing = true;
DoWork(delegate callBack);
this.Processing = false;
}
And some of the XAML:
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<me:ProcessingControl Visibility="{Binding Path=Processing, Converter={StaticResource ResourceKey=BoolToVis}}"/>