【发布时间】:2014-06-16 08:36:14
【问题描述】:
我有这个 XAML 代码,它会引发错误:
“内容”属性设置了多次。
整个代码指向同一种错误。非常感谢您的帮助。
编辑:添加了窗口的 XAML
<Window x:Class="AddressBook.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="AddressBook"
Loaded="WindowLoaded"
SizeToContent="WidthAndHeight"
MinHeight="480"
MinWidth="640">
<Window.Resources>
<ObjectDataProvider x:Key="ContactList"
MethodName ="AddressBook.ContactList,AddressBook" />
<DataTemplate x:Key="ContactNameTemplate" >
<TextBlock Text=" {Binding Path=Firstname}" />
</DataTemplate>
</Window.Resources>
<Grid Background="White" Name="DocumentRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<!-- Menu -->
<RowDefinition Height="Auto"/>
<!-- Tool Bar -->
<RowDefinition Height="Auto"/>
<!-- Content Area -->
<RowDefinition Height="Auto"/>
<!-- Status Bar -->
</Grid.RowDefinitions>
</Grid>
<DockPanel Name="DockPanel_Menu" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0">
<Menu Background="White">
<MenuItem Header="File">
<MenuItem Header="New Contact" Click="LaunchNewContactWizard"/>
<MenuItem Header="New Group" Click="NotImplementedMsg"/>
<Separator />
<MenuItem Header="Properties" Click="NotImplementedMSg"/>
<MenuItem Header="Delete" Click="NotImplementedMsg"/>
<MenuItem Header="Import">
<MenuItem Header="Address book (WAB)..."
Click="NotImplementedMsg"/>
<MenuItem Header="Business card (vCard)..."
Click="NotImplementedMsg"/>
</MenuItem>
<Separator />
<MenuItem Header="Exit" InputGestureText="Alt-F4"
Click="ExitApplication">
<MenuItem.ToolTip>
<ToolTip>
Click here to exit
</ToolTip>
</MenuItem.ToolTip>
</MenuItem>
</MenuItem>
</Menu>
<Menu Background="White">
<MenuItem Header="Edit">
<MenuItem Command="ApplicationCommands.Copy"/>
<MenuItem Command="ApplicationCommands.Paste"/>
</MenuItem>
</Menu>
</DockPanel>
</Window>
过去 3 天我无法真正调试它:(
【问题讨论】:
-
您粘贴的代码是可编译的。你的问题在别的地方。你能粘贴整个窗口或用户控件的 XAML 吗?