材料设计WPF中的SampleMessage对话框

材料设计WPF中的SampleMessage对话框,wpf,vb.net,material-design,material-ui,Wpf,Vb.net,Material Design,Material Ui,嘿,我一直在想如何在我自己的应用程序中调用SampleMessageDialog 到目前为止,这是我表单上一个按钮的代码,该按钮应打开消息框: Private Async Sub BrowseButton_Copy_Click(sender As Object, e As RoutedEventArgs) Handles BrowseButton_Copy.Click msgBoxPop.showPop() End Sub 这是showPop: Imports MaterialDesi

嘿,我一直在想如何在我自己的应用程序中调用SampleMessageDialog

到目前为止,这是我表单上一个按钮的代码,该按钮应打开消息框:

Private Async Sub BrowseButton_Copy_Click(sender As Object, e As RoutedEventArgs) Handles BrowseButton_Copy.Click
    msgBoxPop.showPop()
End Sub
这是showPop

Imports MaterialDesignThemes.Wpf
Imports newRegisterProg.MaterialDesignColors.WpfExample.Domain

Public Class msgBoxPop
    Public Shared Async Sub showPop()
        Dim sampleMessageDialog = New SampleMessageDialog()

        With sampleMessageDialog
            .Message.Text = "TEST!"
        End With

        Await DialogHost.Show(sampleMessageDialog, "RootDialog")
    End Sub
End Class
最后是用户控件:

<UserControl x:Class="MaterialDesignColors.WpfExample.Domain.SampleMessageDialog"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             mc:Ignorable="d" 
             x:Name="messagePOP"
             d:DesignHeight="300" d:DesignWidth="300"
             MaxWidth="400">
    <Grid Margin="16">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock x:Name="Message" 
                   Margin="0 6 0 0"
                   FontSize="18" Grid.Row="0"/>
        <Button Grid.Row="1" 
                IsDefault="True" Style="{DynamicResource MaterialDesignFlatButton}"
                HorizontalAlignment="Right"
                Margin="16 16 16 0"
                Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}">
            ACCEPT
        </Button>
    </Grid>
</UserControl>

在应用程序的XAML中是否有DialogHost

它的一个好位置就在根目录下,在窗口内,包含应用程序的其余部分:

<Window ....>
    <materialDesign:DialogHost>
        ...your app
    </<materialDesign:DialogHost>
</Window>

…您的应用程序

在应用程序的XAML中是否有DialogHost

它的一个好位置就在根目录下,在窗口内,包含应用程序的其余部分:

<Window ....>
    <materialDesign:DialogHost>
        ...your app
    </<materialDesign:DialogHost>
</Window>

…您的应用程序

当然您现在正在代码中添加应用程序内容吗?我不知道VB的具体语法,但在您将应用程序添加到窗口内容之前,请添加一个DialogHost并将所述应用程序添加到DialogHost的内容中。DialogHost扩展了ContentControl,所以只需像标准控件那样使用它。当然。您现在正在代码中添加应用程序内容吗?我不知道VB的具体语法,但在您将应用程序添加到窗口内容之前,请添加一个DialogHost并将所述应用程序添加到DialogHost的内容中。DialogHost扩展了ContentControl,所以只需像标准控件那样使用它。