我尝试用 wpf 为表面 2.0/pixelsense 实现一个简单的菜单。
<s:SurfaceWindow x:Class="MenuTrial.SurfaceWindow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
xmlns:MenuTrial="clr-namespace:MenuTrial"
xmlns:Properties="clr-namespace:MenuTrial.Properties"
Title="MenuTrial"
>
<Grid Name="MenuGrid" Height="102" VerticalAlignment="Bottom">
<s:ScatterView HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<s:ScatterView.Resources>
<Image x:Shared="false" x:Key="IconPhoto" Source="Resources\Icons\photo.png"/>
<Image x:Shared="false" x:Key="IconCopy" Source="Resources\Icons\copy.png"/>
</s:ScatterView.Resources>
<s:ScatterViewItem Height="139"
Width="224"
Orientation="-23"
Background="#FF787878">
<s:ElementMenu
Name="MainMenu"
ActivationMode="AlwaysActive"
ActivationHost="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type s:ScatterViewItem}}}"
>
<s:ElementMenuItem Header="Menu1"/>
<s:ElementMenuItem Header="Menu2"/>
<s:ElementMenuItem Header="{x:Static Resources:Resources.IconPhoto}" Icon="{StaticResource IconPhoto}">
<s:ElementMenuItem Header="{x:Static Resources:Resources.Copy}" Icon="{StaticResource IconCopy}" Command="{x:Static MenuTrial:SurfaceWindow1.ShowMessageCommand}" CommandParameter="{Binding Path=Header, RelativeSource={x:Static RelativeSource.Self}}"/>
<s:ElementMenuItem Header="Menu 3.2" />
<s:ElementMenuItem Header="Menu 3.3"/>
</s:ElementMenuItem>
</s:ElementMenu>
</s:ScatterViewItem>
</s:ScatterView>
<TextBlock x:Name="textMessage" Width="500" Margin="40" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Bottom" FontFamily="Segoe360" FontSize="17" />
</Grid>
问题是,我得到了一个未知的图片错误。键不能为 NULL 或英文。在 Header="{x:Static Resources....
这与 Surface 示例中的完全一样。我只想在单击菜单项时显示一条消息。
谁能帮帮我吗?谢谢