我有材料设计对话框:
<materialDesign:DialogHost CloseOnClickAway="True" IsOpen="{Binding IsOpenDialogAddingEP, UpdateSourceTrigger=PropertyChanged}">
...
</materialDesign:DialogHost>
<Button Command="{Binding CloseDialogAddingEPCommand}"/>
我想在单击按钮时关闭对话框,在代码后面:
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));
}
但按钮没有任何作用,你能告诉我为什么吗?
catspeake
相关分类