wpf 工具栏错误:ToolBar.Overflowmode 在绑定场景中不起作用

发布于 2024-10-01 03:02:54 字数 506 浏览 1 评论 0原文

这有效(将按钮放置在溢出区域):

    <ToolBar>
        <Button ToolBar.OverflowMode="Always">Hit me</Button>
    </ToolBar>

这不起作用(不将按钮放置/保留在溢出区域):

    <ToolBar Grid.Row="3" ItemsSource="{Binding Path=Groups[0].Items}"></ToolBar>

    <DataTemplate DataType="{x:Type local:ItemViewModel}">
        <Button ToolBar.OverflowMode="Always">Hit me</Button>
    </DataTemplate>

有谁知道这个问题是否有解决方法?

This works (places the button in the overflow area):

    <ToolBar>
        <Button ToolBar.OverflowMode="Always">Hit me</Button>
    </ToolBar>

This does not (does not place/keep the button in the overflow area):

    <ToolBar Grid.Row="3" ItemsSource="{Binding Path=Groups[0].Items}"></ToolBar>

    <DataTemplate DataType="{x:Type local:ItemViewModel}">
        <Button ToolBar.OverflowMode="Always">Hit me</Button>
    </DataTemplate>

Does anyone know if there is a workaround for this problem?

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

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

发布评论

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

评论(1

久而酒知 2024-10-08 03:02:55

我找到了一种将溢出应用于所有项目的方法,并使用自定义样式选择器,您可以定制溢出以仅引用与您相关的项目。

静态版本:

    <Style x:Key="itemContainerStyle">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=Description}" Value="Foo">
                <Setter Property="ToolBar.OverflowMode" Value="Always"></Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="ToolBar">
        <Setter Property="ItemContainerStyle" Value="{StaticResource itemContainerStyle}"></Setter>
    </Style>

I found a way of applying overflow to all items, and using a custom style selector, you can probably tailor the overflow to only refer to the items relevant for you.

Static version:

    <Style x:Key="itemContainerStyle">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=Description}" Value="Foo">
                <Setter Property="ToolBar.OverflowMode" Value="Always"></Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="ToolBar">
        <Setter Property="ItemContainerStyle" Value="{StaticResource itemContainerStyle}"></Setter>
    </Style>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文