我是WPF的新手。我正在使用.NET 4.5。
出于某种原因,我的按钮在intellisense中没有Click
属性。当我在下面输入它时,我在Blend中收到“无效标记”错误。
为什么这里没有Click
属性?
我必须使用命令吗?
我的XAML:
<Window x:Class="Project.UI.Windows.windowLoadFiles"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Load Files" Height="350" Width="525">
<DockPanel LastChildFill="True">
<Menu DockPanel.Dock="Top" x:Name="menuMain" IsMainMenu="True" Height="Auto">
<MenuItem Header="_File">
<MenuItem x:Name="menuItem_Main_File_Exit" Header="E_xit" Click="menuItem_Main_File_Exit_Click"></MenuItem>
</MenuItem>
</Menu>
<StackPanel Margin="10">
<GroupBox Margin="5,0,5,5" Header="Source *" HorizontalAlignment="Stretch">
<TextBox x:Name="textSourceDirectory"></TextBox>
<Button x:Name="buttonSelectSourceDirectory" Content="Browse..." Click="buttonSelectSourceDirectory_Click"></Button>
</GroupBox>
</StackPanel>
</DockPanel>
</Window>
答案 0 :(得分:0)
正如上面提到的AjS,在Visual Studio中构建解决方案可以准确地解决问题。
GroupBox
只能有一个子元素。这意味着如果您需要多个,则需要将它们添加到某种类型的Panel
。
以下解决了我的问题:
<Window x:Class="Project.UI.Windows.windowLoadFiles"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Load Files" Height="350" Width="525">
<DockPanel LastChildFill="True">
<Menu DockPanel.Dock="Top" x:Name="menuMain" IsMainMenu="True" Height="Auto">
<MenuItem Header="_File">
<MenuItem x:Name="menuItem_Main_File_Exit" Header="E_xit" Click="menuItem_Main_File_Exit_Click"></MenuItem>
</MenuItem>
</Menu>
<StackPanel Margin="10">
<GroupBox Margin="5,0,5,5" Header="Source *" HorizontalAlignment="Stretch">
<StackPanel>
<TextBox x:Name="textSourceDirectory"></TextBox>
<Button x:Name="buttonSelectSourceDirectory" Content="Browse..." Click="buttonSelectSourceDirectory_Click"></Button>
</StackPanel>
</GroupBox>
</StackPanel>
</DockPanel>
</Window>