如何删除 WPF 工具栏托盘上的下拉图标?

发布于 2024-08-05 02:27:02 字数 451 浏览 2 评论 0原文

如何摆脱下面工具栏项中文本右侧的灰色下拉区域?

替代文本

这是生成它的代码:

ToolBar tb = new ToolBar();
tb.Background = new SolidColorBrush(Colors.Transparent);
Button button = new Button();
button.Content = "test";
button.Click += new RoutedEventHandler(button_Click);
tb.Items.Add(button);
value.ToolBars.Add(tb);

How can I get rid of the grey dropdown area to the right of the text in the toolbar item below?

alt text

Here is the code which produces it:

ToolBar tb = new ToolBar();
tb.Background = new SolidColorBrush(Colors.Transparent);
Button button = new Button();
button.Content = "test";
button.Click += new RoutedEventHandler(button_Click);
tb.Items.Add(button);
value.ToolBars.Add(tb);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野心澎湃 2024-08-12 02:27:02
<ToolBar Height="120">
        <ToolBar.Style>
            <Style TargetType="ToolBar">
                <!-- Not Dropdown Button -->
                <Setter Property="ToolBarTray.IsLocked" Value="True"/>
                <!-- Not Overflow Button -->
                <Setter Property="OverflowMode" Value="Never"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ToolBar}">
                            <ToolBarPanel IsItemsHost="True" Background="WhiteSmoke"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ToolBar.Style>
        <!-- Content -->
        ........
        <!-- End Content -->
</ToolBar>
<ToolBar Height="120">
        <ToolBar.Style>
            <Style TargetType="ToolBar">
                <!-- Not Dropdown Button -->
                <Setter Property="ToolBarTray.IsLocked" Value="True"/>
                <!-- Not Overflow Button -->
                <Setter Property="OverflowMode" Value="Never"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ToolBar}">
                            <ToolBarPanel IsItemsHost="True" Background="WhiteSmoke"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ToolBar.Style>
        <!-- Content -->
        ........
        <!-- End Content -->
</ToolBar>
策马西风 2024-08-12 02:27:02

ToolBar 类中没有属性允许您执行此操作。但您始终可以覆盖 ToolBar 的样式。获取您主题的默认样式。通常该拇指部分称为“OverflowGrid”。只需删除它或将其隐藏即可。

希望能回答您的问题。但我想知道为什么要删除它?您确定需要工具栏控件吗?也许具有适当颜色的原始 ItemsControl 适合您?

There is no property in the ToolBar class which allows you to do this. But you can always override ToolBar's style. Get default style for you theme. Usually that thumb part is called "OverflowGrid". Just remove it or make it hidden.

Hope that answers your question. But I'm wondering why do you want to remove it? Are you sure you need toolbar control there at all? Maybe raw ItemsControl with proper colors will work for you?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文