MaterialDesignXaml dialog from Caliburn.Micro View Model

1.4k views Asked by At

I'm having a problem with showing Dialogs from a View Model. The problem is that the "underlying content is not dimmed and disabled" as the documentation says it should be. If I click on the underlying view the button in the dialog wired to the closed command is sometimes disabled and the user is not able to click it.

I defined the DialogHost in my MainView like this (also tried it in the ShellView):

<materialDesign:DialogHost
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        CloseOnClickAway="True" />

From my MainViewModel I show the dialog like this:

   Dim errView As New ErrorView
   Dim res = Await DialogHost.Show(errView)

I wired up the close command on a button in the ErrorView dialog like this:

Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}"
1

There are 1 answers

2
James Willock On BEST ANSWER

You problem is with the definition of DialogHost; you have it as an empty element.

The DialogHost is a ContentControl. Everything inside is what will become dimmed. So you define it at the root of your main Window/Page XAML, a bit more like:

<materialDesign:DialogHost CloseOnClickAway="True">
  <StackPanel>
    <TextBlock>Hello World</TextBlock>
    <TextBlock>This is the main content of my application</TextBlock>
  </StackPanel>
</materialDesign:DialogHost>