Here I have added a boolean property in model and binding it to Isenabled property of Combobox . And Binding Command to button in which I have added execute() method which sets the property binded to combobox. However this changes isEnable of Button. Is there a way to disable combobox on btn click?
Model:
public class MyPanelModel : BindableBase
{
private bool _MessageVisibilty;
public bool MessageVisibilty
{
get
{
return _MessageVisibilty;
}
set
{
SetProperty(ref _MessageVisibilty, value);
}
}
}
View Model:
private MyPanelModel plModel;
public MyPanelModel MyPnlModel
{
get { return plModel; }
set { SetProperty(ref plModel,value); }
}
private readonly DelegateCommand _hideCommand;
public DelegateCommand DisableOtherControlsCommand
{
get { return _hideCommand; }
}
public MyPanelViewModel()
{
_hideCommand = new DelegateCommand(hideExecute, canExecute);
_hideCommand.RaiseCanExecuteChanged();
}
private void hideExecute()
{
MyPnlModel.MessageVisibilty = false;
}
private bool canExecute()
{
return true;
}
Xaml :
<ComboBox Mandatory="True">
<i:Interaction.Triggers >
<i:EventTrigger EventName="IsEnabled">
<prism:InvokeCommandAction Command="{Binding MyPanelModel.MessageVisibilty,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Button Margin="10" Command="{Binding MyPanelViewModel.DisableOtherControlsCommand}" >Save</Button>