从图片加载菜单 [英] menu loading from picture

查看:65
本文介绍了从图片加载菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在wpf中有一个菜单,我发现了如何在菜单项中放置图片,但是如何将其作为菜单按钮呢?

I have a menu in wpf, and i found how to put a picture in a menu item, but how do you make it as a menu button?

<Grid>
                <Menu x:Name="loadsavemenu" Height="100" Width="200" >

                    <Ellipse x:Name="ellipse" Fill="{StaticResource MenuIcon}" HorizontalAlignment="Left" Margin="0" Width="35" Height="35" StrokeThickness="2" Stroke="White"/>

                    <MenuItem x:Name="Loadmenu"  VerticalAlignment="Top"  FontSize="14" Height="30" Width="100" >



我想加载仅带有椭圆作为菜单按钮的菜单.



i want to load the menu having only the elipse as the menu button.
any help?

推荐答案

您应该将椭圆声明为资源,然后可以将其用作按钮的图标.像这样的东西:

You should declare the ellipse as a resource, and then you could use it as the Icon for the button. Something like this:

<Window.Resources>
        <Ellipse x:Key="ellipse" HorizontalAlignment="Left" Margin="0" Width="35" Height="35"

                     StrokeThickness="2" Stroke="White"/>
    </Window.Resources>
   <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <Menu >
            <MenuItem VerticalAlignment="Top" Height="40" Width="45" Icon="{StaticResource ellipse}"/>
        </Menu>
    </Grid>



希望对您有帮助



Hope this helps


这篇关于从图片加载菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆