关闭材料设计对话框

我有材料设计对话框:


<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));

}

但按钮没有任何作用,你能告诉我为什么吗?


元芳怎么了
浏览 97回答 1
1回答

catspeake

您是否添加了:public&nbsp;partial&nbsp;class&nbsp;Window:Window,&nbsp;INotifyPropertyChanged?
打开App,查看更多内容
随时随地看视频慕课网APP