Sondre
Sondre

Reputation: 364

MaterialDesign multiple dialogs

I am developing a desktop application with mahapp and materialdesign. Im trying to have two diffrent dialogs in the same userControl. They look like this:

<materialDesign:DialogHost x:Name="MachineDialogWindow" Identifier="2" Visibility="{Binding Visibility, ElementName=card}">
<grid></grid>
</materialDesign:DialogHost>

 <materialDesign:DialogHost x:Name="DialogWindow" Visibility="{Binding ActiveDirectoryResult, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource NullVisibilityConverter}}">
<grid></grid>
</materialDesign:DialogHost>

I have removed most of the code to keep it simple. When i try to create a dialoghost in C# like this:

var view = new MachineNameDialogView();
            {
                DataContext = new MachineNameDialogViewModel();
            }
            ;

            //show the dialog
var result = await DialogHost.Show(view, AddAdministratorEventHandlerOpenedEventHandler,
                                         AddAdministratorClosingEventHandler);

It works fine, but shows the window in the wrong Dialoghost. I added a identifier to the first window but i dont know how to pass that along with the Dialoghost.show command Dialoghost.show
I need the dialogClosingEventHandler, but i can see that there is a method overload with Object dialogIdentifier. So my question is it possible to get the best of both worlds and get both? And how can I pass my identifier 2 as an object to the method?

Upvotes: 4

Views: 6376

Answers (1)

Sondre
Sondre

Reputation: 364

I figured it out. And now i feel stupid. The dots on the bottom of the Picture i posted above apperently means there are more overloads. Peek Definition
all i did was right-click on Dialoghost.Show and clicked Peek Definition (Alt+F12) And found

public static Task<object> Show(object content, object dialogIdentifier, DialogOpenedEventHandler openedEventHandler, DialogClosingEventHandler closingEventHandler);

Hope this might atleast help someone in the future :)

Upvotes: 4

Related Questions