Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.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
WPF菜单和标题图像_Wpf_Menu - Fatal编程技术网

WPF菜单和标题图像

WPF菜单和标题图像,wpf,menu,Wpf,Menu,我需要在我的菜单标题中有一个图像而不是文本。我已经写了一个代码,但它没有显示图像 下面是我的xaml部分 <Menu Height="50" Width="50" VerticalAlignment="Top" IsMainMenu="True"> <MenuItem Height="50" Width="50"> <MenuItem.Header>

我需要在我的菜单标题中有一个图像而不是文本。我已经写了一个代码,但它没有显示图像

下面是我的xaml部分

<Menu Height="50" Width="50" VerticalAlignment="Top" IsMainMenu="True">                
            <MenuItem Height="50" Width="50">
                <MenuItem.Header>
                    <Image HorizontalAlignment="Left" Height="50" VerticalAlignment="Top" Width="50" Source="Images/pulsesi_icon_black.PNG"/>
                </MenuItem.Header>

            </MenuItem>

        </Menu>


帮我解决这个问题,我不需要图标。

您可以使用Menuitem.Icon作为标题中的图像

 <MenuItem >
   <MenuItem.Icon>
     <Image Width="20" Height="20" Source="/Resources/Images/Key.jpg" />
   </MenuItem.Icon>
 </MenuItem>


图像。源路径可能错误。你确定,你在同一个项目中有图像,并且图像
BuildAction
设置为
Resrouce
?你有没有图像?没有,我在那里没有看到任何图像,我的文件夹中有图像。你的图像文件夹在哪里?意味着图像文件夹应该在您的项目中,我在我的项目中使用上述代码。