c# - 增加 MenuItem.Icon WPF 的大小

标签 c# wpf xaml menuitem

我遇到了以下困难,我在互联网上的任何地方都找不到解决方案。 我在 WPF 应用程序中有以下菜单

<Menu  Margin="0,0,95,207" FontSize="14">
        <Menu.Resources>
            <Style TargetType="Image">
                <Setter Property="Height" Value="20" />
                <Setter Property="Width" Value="20" />
                <Setter Property="Stretch" Value="Fill"/>
            </Style>
        </Menu.Resources>
        <MenuItem Header="_File" Height="35" Width="55" ScrollViewer.VerticalScrollBarVisibility="Disabled" Grid.IsSharedSizeScope="True" Padding="5,0" ScrollViewer.CanContentScroll="True" UseLayoutRounding="False">
            <MenuItem.Icon>
                <Image Source="pack://siteoforigin:,,,/Resources/text-icon.png" />
            </MenuItem.Icon>
            <MenuItem Header="_Text" Margin="0">
                <MenuItem.Icon>
                    <Image Source="pack://siteoforigin:,,,/Resources/Power - Shut Down.png"  Margin="0,0,0,0"/>
                </MenuItem.Icon>
            </MenuItem>
        </MenuItem>
    </Menu>

无论我尝试修改或调整大小,我都无法使菜单的图标变大,也无法使菜单项高度变大,也无法使菜单项字体大小变大。我希望我的图标至少为 25x25。我猜它的列大小出现在左侧,但我不知道它的名称/属性,所以我调整了它的大小。 提前致谢! :)

最佳答案

试试这个

<MenuItem Height="32" Header="_Text" Margin="0">
   <MenuItem.Icon>
      <Image Source="pack://siteoforigin:,,,/Resources/Power - Shut Down.png" Margin="-2,-2,-2,-2"/>//use negative margin abd item height
   </MenuItem.Icon>
</MenuItem>

关于c# - 增加 MenuItem.Icon WPF 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29081060/

相关文章:

c# - MongoDb 和自引用对象

c# - 获取数据网格中所选项目的行索引

c# - WPF C# - MainWindows.g.cs 中的 "Unable to find namespace"错误

c# - 如何从 XAML 设置 WPF 用户控件属性?

c# - UWP - 将标题行添加到我的 gridview

c# - 如何从 XAML 中的静态成员引用属性?

c# - 在 Button 上关闭或重启本地计算机

c# - EntitySet System.InvalidOperationException - "the entity type is not part of the model for the current context"

c# - 从 FLV 中提取音频数据并注入(inject) MP3

wpf - 使 WPF 中的列表框项目不可选择