menuitem 相关问题

菜单项是菜单的子元素,其为用户提供查看和执行特定应用程序操作的手段。

为什么 MenuItem 标题前面有下划线?

如果您声明 MenuItems,我总是看到它们的 Header 属性声明如下: ...

回答 2 投票 0

执行导出/导入菜单命令?

我有一个导入(和导出)按钮,可以很好地放置在视图中。 var body: 一些视图 { 按钮(操作:{ 正在导入 = true }, 标签: { 标签(“导入”,

回答 2 投票 0

Windows 11 - 如何修改 Windows 资源管理器上下文菜单中一组项目的标题?

在我的一个应用程序中,我在 Windows 11 的 Windows 资源管理器上下文菜单中添加了一个新项目。这效果很好,但现在我想添加一组项目。我可以通过更新

回答 1 投票 0

菜单项样式

我有一个包含以下项目的上下文菜单 我有一个包含以下项目的上下文菜单 <ContextMenu x:Name="NotificoContextMenu" x:Shared="false" x:Key="SysTrayMenu" x:FieldModifier="public" Loaded="NotificoContextMenu_Loaded" Style="{DynamicResource conte}"> <MenuItem Header="Connect" x:Name="ConnectMenuItem" x:FieldModifier="public" /> <MenuItem Header="Ping" Command="{Binding PingCommand}"/> <MenuItem Header="Show Window" Command="{Binding ShowWindowCommand}" /> <Separator /> <MenuItem Header="Exit" Command="{Binding ExitApplicationCommand}" /> </ContextMenu> 对于 ConnectMenuItem,我从代码中添加菜单项 我有一个上下文菜单样式,它适用于所有菜单项,除了我从代码中添加的菜单项,我应该做什么 这是我的上下文菜单的样式 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style TargetType="{x:Type ContextMenu}" x:Key="conte"> <Setter Property="Background" Value="{DynamicResource PrimaryDark}" /> <Setter Property="Foreground" Value="{DynamicResource Secendery}" /> <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="HasDropShadow" Value="True" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ContextMenu}"> <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding Foreground}" BorderThickness="0.5" CornerRadius="5"> <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" /> </Border> <ControlTemplate.Triggers> <Trigger Property="HasDropShadow" Value="true"> <Setter TargetName="Border" Property="Padding" Value="0,3,0,3" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> 日夜寻找时发现了一些灵魂出处 这是完整的 Windows 资源文件: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style TargetType="{x:Type ContextMenu}" x:Key="conte"> <Setter Property="Background" Value="{DynamicResource PrimaryDark}" /> <Setter Property="Foreground" Value="{DynamicResource Secendery}" /> <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="HasDropShadow" Value="True" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ContextMenu}"> <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding Foreground}" BorderThickness="0.85" CornerRadius="5"> <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"> </StackPanel> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type MenuItem}" > <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type MenuItem}"> <Grid SnapsToDevicePixels="true"> <DockPanel> <ContentPresenter x:Name="Icon" ContentSource="Icon" Margin="4,0,6,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/> <Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="10,0,0,0" Visibility="Collapsed" VerticalAlignment="Center"/> <ContentPresenter x:Name="content" ContentSource="Header" Margin="10,3" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> </DockPanel> <Popup x:Name="PART_Popup" AllowsTransparency="True" Focusable="false" HorizontalOffset="0" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Placement="Left" VerticalOffset="0"> <Border BorderThickness="0.85" CornerRadius="2" BorderBrush="{DynamicResource Secendery}" Background="{TemplateBinding Background}"> <ScrollViewer x:Name="SubMenuScrollViewer" CanContentScroll="true" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}"> <Grid RenderOptions.ClearTypeHint="Enabled"> <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="true" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle"/> </Grid> </ScrollViewer> </Border> </Popup> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="TextBlock.Foreground" Value="White" TargetName="content"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>

回答 1 投票 0

MenuItem SubMenu 出现在 ContextMenu 的左侧而不是默认的

这个问题与这里的帖子相关 - 原来的问题已经解决,但随后又出现了另一个问题。 正如您所看到的,MenuItem 出现在错误的一侧 由于上一问题与

回答 1 投票 0

检测菜单项文本(和 ID)

代码: 自动 pMenuEdit = GetCongregationSubMenu(1); if (pMenuEdit != nullptr) { const int iSize = pMenuEdit->GetMenuItemCount(); 对于 (int i = 0; i < iSize; i++) { CString

回答 1 投票 0

如何在MUI菜单中选择多个菜单项并返回选择的值

我为 MUI 菜单中的每个 MenuItem 创建了一个复选框。用户可以一次选择多个菜单项。 有没有办法获取所选菜单项的值? 因为如果我把 event.ta...

回答 2 投票 0

在特定菜单的范围内为 WPF 中的菜单项分隔符创建默认样式

我正在尝试更改分隔符在 WPF 上下文菜单中的显示方式。上下文菜单有自己的默认样式,它已经成功地将样式应用到其所有菜单项。 <question vote="1"> <p>我正在尝试更改分隔符在 WPF 上下文菜单中的显示方式。上下文菜单有自己的默认样式,它已经成功地将样式应用到其所有菜单项。</p> <pre><code>&lt;Style BasedOn=&#34;{StaticResource ContextMenuBaseStyle}&#34; TargetType=&#34;{x:Type local:ViewportContextMenu}&#34;&gt; &lt;!-- Defining this style in Style.Resources means ALL menu items within the Context Menu, no matter how nested, use this style by default. --&gt; &lt;Style.Resources&gt; &lt;Style BasedOn=&#34;{StaticResource MenuItemBaseStyle}&#34; TargetType=&#34;{x:Type MenuItem}&#34;&gt; &lt;!-- Set the icon of all menu items to the one associated with their data context --&gt; &lt;Setter Property=&#34;Icon&#34; Value=&#34;{StaticResource ViewportMenuItemIcon}&#34;/&gt; &lt;/Style&gt; &lt;Style TargetType=&#34;{x:Type Separator}&#34;&gt; &lt;!-- Make the separators big and red so I know this style is working. --&gt; &lt;Setter Property=&#34;Background&#34; Value=&#34;Red&#34;/&gt; &lt;Setter Property=&#34;Margin&#34; Value=&#34;100&#34;/&gt; &lt;/Style&gt; &lt;/Style.Resources&gt; &lt;/Style&gt; </code></pre> <p>通过将 MenuItem 样式定义为无键,并在 ContextMenu 样式的资源内,我似乎能够在 ContextMenu 控件范围内为 MenuItem 创建“默认样式”。</p> <p>我想我可以对分隔符做同样的事情,但这种样式似乎没有得到应用(与 WPF 的情况一样,很难弄清楚给定控件上实际激活的样式是什么)</p> </question> <answer tick="false" vote="0"> <p>当您刚刚设置 <pre><code>Style.TargetType</code></pre> 时,隐式 <pre><code>Style</code></pre> 将仅针对 <pre><code>Separator</code></pre>(或 <pre><code>Menu</code></pre>)之外的 <pre><code>ContextMenu</code></pre> 控件。这是因为 <pre><code>Menu</code></pre> 通过按键显式加载 <pre><code>Style</code></pre>。 该键被定义为 <a href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.menuitem.separatorstylekey?view=windowsdesktop-8.0#remarks" rel="nofollow noreferrer"><pre><code>MenuItem.SeparatorStyleKey</code></pre></a> 静态属性。 这意味着您必须显式覆盖使用此键的 <pre><code>Style</code></pre>,以便当 <pre><code>Menu</code></pre> 使用此键查找资源时找到您的自定义 <pre><code>Style</code></pre>:</p> <pre><code>&lt;Style x:Key=&#34;{x:Static MenuItem.SeparatorStyleKey}&#34; TargetType=&#34;{x:Type Separator}&#34;&gt; &lt;!-- Make the separators big and red so I know this style is working. --&gt; &lt;Setter Property=&#34;Background&#34; Value=&#34;Red&#34; /&gt; &lt;Setter Property=&#34;Margin&#34; Value=&#34;10&#34; /&gt; &lt;/Style&gt; </code></pre> <p>请注意,在设置子菜单项的样式时可能会遇到相同的问题。他们也使用显式键。<br/> 您可以查看 Microsoft Docs:<a href="https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/menu-styles-and-templates?view=netframeworkdesktop-4.8#menu-and-menuitem-controltemplate-example" rel="nofollow noreferrer">Menu 和 MenuItem ControlTemplate 示例</a>以了解所使用的按键。</p> </answer> </body></html>

回答 0 投票 0

为什么 item.getMenuInfo() 为 null?

在我的ListVeiw项目中,我有4-8个ImageView(其中一些是不可见的,取决于某些值)和4个TextView。 当我长按 Listview 的项目时 (AdapterContextMenuInfo) item.getMenuInfo()

回答 4 投票 0

点击搜索视图时删除多余的菜单

在我的项目中,我尝试在单击搜索视图时删除额外的菜单,并在取消搜索视图时返回菜单。请找到下面的屏幕截图 我使用下面的代码来隐藏...

回答 1 投票 0

图像无法显示在裸菜单中,但不能显示在网格的其余部分中

我有以下 wpf 网格块。我有一个名为 truc.PNG 的图像,这是一个尺寸为 16x16 像素的小文件图像。我可以在图像块中看到它,但不能在菜单栏项目之一中看到它。我...

回答 1 投票 0

是否有任何 Win32 API 可以在运行时隐藏和显示菜单项?

我已经从资源文件加载了菜单: IDR_MENU1 菜单可丢弃 开始 MENUITEM“菜单项1”,IDM_CTX_M1 MENUITEM“菜单项2”,IDM_CTX_M2 菜单项分隔符 菜单项“菜单项...

回答 1 投票 0

有人可以帮忙吗?使用 Kotlin 的 onOptionsItemSelected 启动新活动

查看文档和线程后,我找不到适合我的案例的解决方案,我想知道我是否可以获得一些帮助/轻微的推动。我还没有完全理解这个功能并且正在教学

回答 1 投票 0

如何为下拉菜单制作过渡效果

我在使用 CSS 制作下拉菜单时遇到问题(尝试过 JS,效果相同,但不起作用)。 当我单击按钮打开子菜单时,它会立即出现,如何才能使过渡顺利?

回答 1 投票 0

如何更改 AntD Menu.Item 内联颜色

当焦点位于 Menu.Item 上时,如何自定义它的边框右侧颜色? 在菜单中设置内联模式的默认边框右颜色

回答 1 投票 0

突出显示当前菜单项对某些项目不起作用

我为客户制作了这个网站:https://ccf2up.com/ 它应该突出显示当前菜单项。这是通过简单的 CSS 实现的: .当前菜单项a{ 颜色:#FFFFFF!重要; 背景:#2889AE!

回答 1 投票 0

MenuItem 导致应用程序变慢

我有一个显示我的数据的DataGrid(该集合包含不止一种类型的数据, 我为每种类型编写了一个 DataTemplate)。基本上,我的 DataGrid 的作用就像一个属性网格。 通常,

回答 1 投票 0

如何在Odoo中找到菜单元素的id?

当我激活开发人员模式时,我无法找到可以在新菜单项标签中用作父项的菜单 ID。配置中是否有特定位置可以找到它?

回答 1 投票 0

特定页面上的不同菜单

我的 WordPress 网站上有一个名为“CordialTech”的页面。 在此页面上时,我想显示不同的标题菜单。 我知道一个名为“条件菜单”的插件可以实现......

回答 2 投票 0

如何修复/更改网站移动版本中几乎看不见的菜单项? (以前很好,后来 Weebly 做了改变)

背景 几年前,我为自己的企业建立了第一个 Weebly 网站 ( www.smehelper.com ) 移动版本“曾经”看起来很棒! 自那以后 然而...Weebly 大约一年前做了一些改变...

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.