WPF 分隔符未显示在工具栏 OverflowPanel 中

发布于 2024-11-27 08:10:59 字数 1070 浏览 0 评论 0原文

当您缩小工具栏的大小时,WPF 分隔符似乎不会显示在工具栏的溢出面板中;有什么办法让它显示出来吗? (我可以通过使用空的彩色标签来解决这个问题,但我仍然想知道为什么分隔符不起作用)。

示例:在 mainwindow.xaml 中创建一个新的 WPF 项目:

  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <ToolBar HorizontalAlignment="Left" Name="toolBar1">
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Separator />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
    </ToolBar>
  </Grid>

it seems that a WPF Separator doesn't show up in a ToolBar's Overflow panel when you shrink the size of the toolbar; is there someway to make it show? (I can get around it by using an empty colored label, but I'd still like to know why separators don't work).

An example: create a new WPF project with in the mainwindow.xaml:

  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <ToolBar HorizontalAlignment="Left" Name="toolBar1">
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Separator />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
    </ToolBar>
  </Grid>

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

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

发布评论

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

评论(2

誰ツ都不明白 2024-12-04 08:10:59

我的问题在MSDN上得到了解答;你需要将它包裹在网格中并将其旋转 90 度:

 <Grid Width="10">
     <Separator>
         <Separator.LayoutTransform>
             <RotateTransform Angle="90" />
         </Separator.LayoutTransform>
     </Separator>
 </Grid>

但是在我的实际项目中,由于某种原因我不需要进行旋转。

My problem was answered on MSDN; you need to wrap it in a grid and rotate it 90 degrees:

 <Grid Width="10">
     <Separator>
         <Separator.LayoutTransform>
             <RotateTransform Angle="90" />
         </Separator.LayoutTransform>
     </Separator>
 </Grid>

However in my actual project I didn't need to do the rotation for some reason or other.

烟柳画桥 2024-12-04 08:10:59

请尝试一下,这显示了带有溢出的分隔符​​,您可以通过“overflowmode”属性设置每个元素的溢出。

<ToolBarPanel>
        <ToolBar ToolBarTray.IsLocked="True"  Name="toolBar1">
            <ToolBar Band="1" BandIndex="1">
                <Button Content="ASDF" />

                <Button Content="ASDF" />

                <Button Content="ASDF" />

            </ToolBar>
            <Separator/>
            <ToolBar Band="2" BandIndex="1">
                <Button Content="ASDF" />
                <Button Content="ASDF" />

            </ToolBar>
            <Separator/>
            <ToolBar Band="2" BandIndex="2">
                <Button Content="ASDF" />
                <Button Content="ASDF" />
                <Button Content="ASDF" ToolBar.OverflowMode="Always"/>
                <Button Content="ASDF" ToolBar.OverflowMode="Always" />

            </ToolBar>
        </ToolBar>
    </ToolBarPanel>

希望这对您有帮助。

Please try it this is showing separator with overflow and you can set the overflow with each element by "overflowmode" property.

<ToolBarPanel>
        <ToolBar ToolBarTray.IsLocked="True"  Name="toolBar1">
            <ToolBar Band="1" BandIndex="1">
                <Button Content="ASDF" />

                <Button Content="ASDF" />

                <Button Content="ASDF" />

            </ToolBar>
            <Separator/>
            <ToolBar Band="2" BandIndex="1">
                <Button Content="ASDF" />
                <Button Content="ASDF" />

            </ToolBar>
            <Separator/>
            <ToolBar Band="2" BandIndex="2">
                <Button Content="ASDF" />
                <Button Content="ASDF" />
                <Button Content="ASDF" ToolBar.OverflowMode="Always"/>
                <Button Content="ASDF" ToolBar.OverflowMode="Always" />

            </ToolBar>
        </ToolBar>
    </ToolBarPanel>

Hope this help you.

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