如何在 WPF 工具栏中更改 ToolBarOverflowPanel 的 WrapWidth 值

How to Change WrapWidth value of ToolBarOverflowPanel in WPF ToolBar

需要修改ToolBar中ToolBarOverflowPanel的WrapWidth值。

尝试使用 ToolBar 设置 ToolBarOverflowPanel WrapWidth 的值 Style.it 显示错误

<ToolBar Name="myToolBar" Height="50"  Band="1" ToolBarTray.IsLocked="True" >
            <ToolBar.Style>
                <Style TargetType="ToolBarOverflowPanel">
                    <Setter Property="WrapWidth" Value="20"></Setter>
                </Style>
            </ToolBar.Style>
            <Button Height="24" Width="24" Margin="4" BorderBrush="Black">

            </Button>
            <Button Height="24" Width="24"  Margin="4" BorderBrush="Black">

            </Button>
             <Grid>
                <Separator Margin="4">
                    <Separator.LayoutTransform>
                        <RotateTransform Angle="90" />
                    </Separator.LayoutTransform>
                </Separator>
            </Grid>
            <Button Height="24" Width="24" Margin="4" BorderBrush="Black">

            </Button>
            <Button Height="24" Width="24"  Margin="4" BorderBrush="Black">

            </Button>
            <Grid>
                <Separator Margin="4">
                    <Separator.LayoutTransform>
                        <RotateTransform Angle="90" />
                    </Separator.LayoutTransform>
                </Separator>
            </Grid>


            <Button Height="24" Width="24" Margin="4" BorderBrush="Black">

            </Button>
            <Button Height="24" Width="24"  Margin="4" BorderBrush="Black">


        </ToolBar>

需要在不更改工具栏模板的情况下更改 wrapwidth 值。

问题是工具栏在其模板中使用了另一个控件。如果您想覆盖默认值 style/behavior,那么您需要查看 here