Materialdesigninxamltoolkit: CLOSING DIALOG HOST AUTOMATICALLY

Created on 27 Oct 2015  ·  12Comments  ·  Source: MaterialDesignInXAML/MaterialDesignInXamlToolkit

i try to understand how to close the dialog host automatically .

In the example of the toolkit you call this control with

       var view = new SampleDialog();

        //show the dialog
        var result = await DialogHost.Show(view, "RootDialog", ClosingEventHandler);

        //check the result...
        Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL"));

how i can close the dialog automatically ??i know presing cancel can close but i need close the dialog after login automatically ....the can you help me please?

Most helpful comment

Just show your love by hitting the ⭐ button! 😜

All 12 comments

Hi @zirius666

You can also show the dialog by using IsOpen which you can set from a view mode/code behind etc.

But now you have asked this question I am thinking I can enhance the .Show method to provide some sort of cancellation/end token.

...watch this space...

Then, there is no way for close without a button?

Yes...you can close via binding IsOpen. But I am going to add more to the Show method to make it easier.

can you show me an example please?

IsOpen is for wpf:DialogHost
but cant close , im using the type of dialog host who calls a user control , wpf:DialogHost and DialogContent is not Used.
Sorry, im starting with xaml pages
thnks man

Just working on some API additions, and I will also add a new example. Will report back when done.

thanks man

OK, I've enhanced the .Show API so you can get hold of a "Session" to update the progress dialog and close it on demand. I've added to dialog sample 3 to illustrate this.

I've also added a sample 4 which illustrates using IsOpen purely in a MVVM binding scenario.

thanks again man!

Just show your love by hitting the ⭐ button! 😜

i cant see the image of your mention of button but thanks :+1:

Hello... Who can share the answer with me?

I'm trying to auto-close a MessageDialog opened into DialogHost after x seconds but i can to achieve this.

@enrmadriv you will need to manually close the dialog yourself. The simplest approach is to use a DispatcherTimer and close the dialog when the timer ticks.

Was this page helpful?
0 / 5 - 0 ratings