我有材料设计对话框:
<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));
}
但是按钮什么也不做,你能说出原因吗?
答案 0 :(得分:1)
您添加了吗?
public partial class Window:Window, INotifyPropertyChanged
?