UWP ContentDialog禁用PrimaryButton

时间:2018-11-30 19:48:49

标签: xaml uwp

我有一个ContentDialog,它链接了它

<ContentDialog
    x:Class="ParadigmaN.Apps.Common.Controls.EditPersonContentDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:ParadigmaN.Apps.Common.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Uid="EditorPersonas"
    Title=""
    PrimaryButtonText="Aceptar"
    SecondaryButtonText="Cancelar"
    PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
    SecondaryButtonClick="ContentDialog_SecondaryButtonClick"
    PrimaryButtonCommand="{Binding ElementName=CtrPerson,Path=DataContext.GuardarCommand}">
    <Grid>
        <local:PersonControl x:Name="CtrPerson"/>
    </Grid>
</ContentDialog>

但是即使我的CanExecuteCommand返回false,PrimaryButton仍保持启用状态。

如何通过ContentDialog控制PrimaryButton的启用状态?

1 个答案:

答案 0 :(得分:1)

有一个名为 IsPrimaryButtonEnabled 的属性,您可以使用该属性启用或禁用ContentDialog的PrimaryButton。

https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.contentdialog.isprimarybuttonenabled