开发者

WPF Separator not showing in ToolBar OverflowPanel

开发者 https://www.devze.com 2023-03-23 10:13 出处:网络
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 l

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 Co开发者_JAVA技巧ntent="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
      <Button Content="ASDF" />
    </ToolBar>
  </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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号