I have MainWindow which has its viewmodel MainWindowViewModel. Inside the window there is one textbox which accepts the user's input and a few radio buttons to filter the search and one button. The button action is bound to the viewmodel using a command like:
<Button x:Name="btnSearch" Command="{Binding SearchByCommand, Mode=OneWay}" />
Inside ViewModel there is:
public ICommand SearchByCommand
{
get
{
if (_SearchByCommand == null)
{
_SearchByCommand = new RelayCommand(
x => this.LoadData(this.SearchBy),
x => { return !string.IsNullOrEmpty(this.SearchText); }
);
}
return _SearchByCommand;
}
}
And LoadData:
private void LoadData(string searchBy)
{
switch(searchBy)
...
}
This works perfectly, but I don't know how to implement a progressbar in this solution. When the user clicks on the search button, the progressbar should start the progress and freeze the current UI. After loading data in the LoadData method the progressbar's progresscount should end and enable the UI again.