I have material design dialog:
<materialDesign:DialogHost CloseOnClickAway="True" IsOpen="{Binding IsOpenDialogAddingEP, UpdateSourceTrigger=PropertyChanged}">
...
</materialDesign:DialogHost>
<Button Command="{Binding CloseDialogAddingEPCommand}"/>
And I want to close the dialog on clicking the button, In code behinde:
public ICommand CloseDialogAddingEPCommand { get; private set; }
public MyPage()
{
InitializeComponent();
DataContext = this;
CloseDialogAddingEPCommand = new RelayCommand(CloseDialogAddingEP);
}
void CloseDialogAddingEP()
{
IsOpenDialogAddingEP = false;
}
private bool isOpenDialogAddingEP;
public bool IsOpenDialogAddingEP
{
get { return isOpenDialogAddingEP; }
set
{
isOpenDialogAddingEP = value;
OnPropertyChanged("IsOpenDialogAddingEP");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
but the button doesn't do nothing, can you tell why?
Have you added:
public partial class Window:Window, INotifyPropertyChanged
?