简体   繁体   中英

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. How to do that? Please help me!

When you calling the ShowAsync method of ContentDialog pass the 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

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

        }

Have a look at the PopUp control and its IsOpen property. I hope thats more suitable in your case though the ContentDialog has Hide() method to hide it.

Documented it here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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