gpt4 book ai didi

xaml - UWP - 单击空白区域关闭我的内容对话框

转载 作者:行者123 更新时间:2023-12-02 00:35:31 26 4
gpt4 key购买 nike

我为我的 UWP 应用程序创建了一个内容对话框,其中涉及一个集中的 UI 元素和周围的空白区域。但是内容对话框没有像“IsLightDismissEnabled”这样的属性,可以在单击 UIELEMENT 区域以外的区域时关闭对话框.我怎样才能实现它?

最佳答案

在内容对话框背后的代码中:

public sealed partial class CustomDialog : ContentDialog
{
public CustomDialog()
{
this.InitializeComponent();

Boolean isHide;

Window.Current.CoreWindow.PointerPressed += (s, e) =>
{
if (isHide)
Hide();
};

PointerExited += (s, e) => isHide = true;
PointerEntered += (s, e) => isHide = false;
}
}

关于xaml - UWP - 单击空白区域关闭我的内容对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33208369/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com