user3821206
user3821206

Reputation: 619

close a ContentDialog after LostFocus on it and click on the MainPage Interface

I have used a ContentDialog to create a PopUp ContentDialog like the one in the Groove App:

enter image description here

the problem is that,I can't close it when I click on any part of the MainPage Interface and loose focus,I have tried like this,but it doesn't work :(,it closes only after I send data from the ContentDialog

MainPage.xaml:

private void MenuButton_Click(object sender, RoutedEventArgs e)
    {

            AddFavoris formTask = new AddFavoris();
            t = formTask.ShowAsync();
            string f = formTask.Opgave;
            formTask.LostFocus += new RoutedEventHandler(formTask_LostFocus);

       }


private void formTask_LostFocus(object sender, RoutedEventArgs e)
        {
            t.Cancel();
        }

so,is there any solutions can I use to have a ContrentDialog that will be closed after a Click on the MainPage interface and lost focus on it thanks for help

Upvotes: 0

Views: 153

Answers (1)

Gaurav
Gaurav

Reputation: 195

Use Flyout instead of using a ContentDialog. Flyouts can be dismissed by tapping or clicking somewhere outside the flyout.

For more information: Guidelines for flyouts, Guidelines for dialog controls

Upvotes: 1

Related Questions