【发布时间】:2017-01-16 05:49:47
【问题描述】:
大家好,我想弄清楚如何在我自己的应用程序中调用 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>
目前,当我单击按钮时,会出现以下错误:
附加信息:未加载 DialogHost 实例。
上线:
Await DialogHost.Show(sampleMessageDialog, "RootDialog")
【问题讨论】:
标签: wpf vb.net material-design material-ui