很抱歉这个非常业余的问题,但我无法完成这项工作。我想制作一个自定义字体对话框窗口(只是为了了解它是如何完成的)并且根据我使用 Google 找到的内容,我应该创建一个我想要显示的窗口实例,然后调用 Show()或 ShowDialog() 方法。然而,智能感知弹出窗口没有显示这些方法可用,并且确实代码没有编译并抱怨这些方法不存在。是否有一些非常简单的东西我错过了或者我只是很远?
Imports System.IO
Class MainWindow
Public font_dialog As Window1 = New Window1
// ... Removed code that was not pertinent
Private Sub menu_font_Click(sender As System.Object, e As _
System.Windows.RoutedEventArgs) Handles menu_font.Click
// does not compile
font_dialog.Show()
End Sub
End Class
这是确切的错误消息:
错误 1“显示”不是“WpfApplication1.Window1”的成员。C:\Users\notmyrealusername\documents\visual studio 2010\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml.vb 24 9 WpfApplication2
Window1 的 XAML:
<UserControl x:Class="Window1"
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"
mc:Ignorable="d" Height="453" Width="600" DataContext="{Binding}">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="575*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TabControl Height="429" HorizontalAlignment="Left" Margin="12,12,0,0" Name="TabControl1" VerticalAlignment="Top" Width="576" Grid.ColumnSpan="2">
<TabItem Header="Paramètres généraux" Name="TabItem1">
<Grid>
<ComboBox Height="23" HorizontalAlignment="Left" Margin="53,14,0,0" Name="ComboBox1" VerticalAlignment="Top" Width="213" />
<Label Content="Police" Height="28" HorizontalAlignment="Left" Margin="6,14,0,0" Name="Label1" VerticalAlignment="Top" />
<Label Content="Styles" Height="28" HorizontalAlignment="Left" Margin="6,43,0,0" Name="Label2" VerticalAlignment="Top" />
<ListBox Height="100" HorizontalAlignment="Left" Margin="53,43,0,0" Name="ListBox1" VerticalAlignment="Top" Width="213" SelectionMode="Multiple" />
</Grid>
</TabItem>
</TabControl>
</Grid>
</UserControl>