简体   繁体   English

如何通过在Windows Phone 8.1中点击它的网站来解雇ContentDialog?

[英]How to dismiss a ContentDialog by tapping out site of it in Windows Phone 8.1?

I have a problem with ContentDialog, as you knew, a ContentDialog can be dismissed when we tap to its button, but now, I want to dismiss this by tapping to the out site section of it. 如您所知,ContentDialog存在问题,当我们点击它的按钮时,可以关闭ContentDialog,但是现在,我想通过点击它的外部站点部分来关闭它。 How to do that? 怎么做? Please help me! 请帮我!

When you calling the ShowAsync method of ContentDialog pass the CancellationTokenSource(cts); 当您调用ContentDialog的ShowAsync方法时,传递CancellationTokenSource(cts);

 CancellationTokenSource cts;
 cts = new CancellationTokenSource();
contentDialog.ShowAsync().AsTask(cts.Token); 

listen for Tapped event of the page. 监听页面的点击事件。 Cancel the task(ContenDialog task) inside event method like below 取消事件方法中的任务(ContenDialog任务),如下所示

void Page_Tapped(object sender, TappedRoutedEventArgs e)
        {
           contentDialog.Hide();
            cts.Cancel();

        }

Have a look at the PopUp control and its IsOpen property. 看看PopUp控件及其IsOpen属性。 I hope thats more suitable in your case though the ContentDialog has Hide() method to hide it. 我希望在你的情况下更合适,虽然ContentDialog有Hide()方法来隐藏它。

Documented it here . 记录在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM