显示 VB.NET WPF 窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12664958/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Display VB.NET WPF window
提问by ApplePie
Sorry for this extremely amateur question, but I cannot make this work. I want to make a custom font dialog window (just for the heck of learning how it would be done) and from what I have found using Google, I should create an instance of the window I want to show and then call the Show() or ShowDialog() methods. However the intellisense popup does not show such methods as available and indeed the code does not compile and complains that those methods don't exist. Is there something really simple I am missing or am I just way off ?
很抱歉这个非常业余的问题,但我无法完成这项工作。我想创建一个自定义字体对话框窗口(只是为了学习如何完成),并且根据我使用 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
Here is the exact error message:
这是确切的错误消息:
Error 1 'Show' is not a member of 'WpfApplication1.Window1'. C:\Users\notmyrealusername\documents\visual studio 2010\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml.vb 24 9 WpfApplication2
错误 1“显示”不是“WpfApplication1.Window1”的成员。C:\Users\notmyrealusername\documents\visual studio 2010\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml.vb 24 9 WpfApplication2
XAML for Window1:
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>
采纳答案by Henk Holterman
'Show' is not a member of 'WpfApplication1.Window1'.
“显示”不是“WpfApplication1.Window1”的成员。
That mans your Window1is not a (valid) Window ...
那芒你Window1不是一个(有效的)窗口......
Post the first lines of the XAML and the code behind.
发布 XAML 的第一行和后面的代码。
Also, you probably want to call ShowDialog(), but that is a separate issue.
此外,您可能想调用 ShowDialog(),但这是一个单独的问题。

