我有材料設(shè)計(jì)對(duì)話框:<materialDesign:DialogHost CloseOnClickAway="True" IsOpen="{Binding IsOpenDialogAddingEP, UpdateSourceTrigger=PropertyChanged}">...</materialDesign:DialogHost><Button Command="{Binding CloseDialogAddingEPCommand}"/>我想在單擊按鈕時(shí)關(guān)閉對(duì)話框,在代碼后面: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));}但按鈕沒(méi)有任何作用,你能告訴我為什么嗎?
1 回答

catspeake
TA貢獻(xiàn)1111條經(jīng)驗(yàn) 獲得超0個(gè)贊
您是否添加了:
public partial class Window:Window, INotifyPropertyChanged
?
- 1 回答
- 0 關(guān)注
- 149 瀏覽
添加回答
舉報(bào)
0/150
提交
取消