Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# wpf表面2.0元素菜单项_C#_Wpf_Visual Studio 2010_Xaml_Pixelsense - Fatal编程技术网

C# wpf表面2.0元素菜单项

C# wpf表面2.0元素菜单项,c#,wpf,visual-studio-2010,xaml,pixelsense,C#,Wpf,Visual Studio 2010,Xaml,Pixelsense,我尝试用wpf为surface 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.

我尝试用wpf为surface 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>

问题是,我犯了一个未知的错误。密钥不能为空,否则它将是英文的。在标题处=“{x:Static Resources…”

这和表面样品完全一样。我只是想在单击菜单项时显示一条消息


有人能帮我吗?Thx

如果您在
资源
部分下定义此
菜单项
,您需要为其提供一个
x:Key
值。没有Key,无法声明资源-

<s:ElementMenuItem Header="{x:Static Resources:Resources.IconPhoto}"
                   Icon="{StaticResource IconPhoto}"
                   x:Key="MyMenuItem">
                  ....
</s:ElementMenuItem>

....

我已经在开始时声明了x:Key,您需要为您在字典中放置的每个资源声明它。如果您将MenuItem放置在Resources部分,您也需要将其设置为。抱歉,但我不明白。该键如何帮助我查找ressourcetoolip表示无法解析sybol的“资源”,而其他地方(如图标)则表示MS.Internal.Design.Metadata.ReflectionTypeNode.能否显示更多xaml代码?如果没有更多详细信息,您很难实现目标。现在整个xaml代码都已联机。我希望您能够理解我的意图。thx