本文介绍了如何在WPF APP中更改ToolBarPanel的边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工具栏面板,但是它不提供属性border,borderbrush等.它也不提供属性"ControlTemplate"来对其进行自定义.
如何更改ToolBarPanel的边框?

I have a toolbarpanel but it doesnt provide property border, borderbrush, etc. Also it doesnt provide property "ControlTemplate" to customize it.
How to change a border of ToolBarPanel?

推荐答案

<Border Name="ToolBarPanelBorder" BorderThickness="5" BorderBrush="Black">
                <ToolBarPanel  HorizontalAlignment="Stretch"  Name="toolBarPanel1" VerticalAlignment="Stretch" >
                    <Button Height="25" >Whazzzup!</Button>
                    <Button Height="25" >Whazzzup!</Button>
                    <Button Height="25" >Whazzzup!</Button>
                </ToolBarPanel>
        </Border>




但是尝试使用网格行吗?




But try using a grid row?

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="40" />
        <RowDefinition Height="273*" />
    </Grid.RowDefinitions>
    <Border Name="ToolBarPanelBorder" BorderThickness="5" BorderBrush="Black">
        <ToolBarPanel Grid.Row="0"   HorizontalAlignment="Stretch"  Name="toolBarPanel1" VerticalAlignment="Stretch" Orientation="Horizontal" Height="27">
                <Button Height="25" >Whazzzup!</Button>
                <Button Height="25" >Whazzzup!</Button>
                <Button Height="25" >Whazzzup!</Button>
            </ToolBarPanel>
    </Border>
</Grid>



似乎可以工作.

您还可以更改BG颜色



Seems to work.

You can also change BG colour as well

<Grid>
      <Grid.RowDefinitions>
          <RowDefinition Height="40" />
          <RowDefinition Height="273*" />
      </Grid.RowDefinitions>
      <Border Name="ToolBarPanelBorder" BorderThickness="5" BorderBrush="Black" Background="Aquamarine">
          <ToolBarPanel Grid.Row="0"   HorizontalAlignment="Stretch"  Name="toolBarPanel1" VerticalAlignment="Stretch" Orientation="Horizontal" Height="27">
                  <Button Height="25" >Whazzzup!</Button>
                  <Button Height="25" >Whazzzup!</Button>
                  <Button Height="25" >Whazzzup!</Button>
              </ToolBarPanel>
      </Border>
  </Grid>


这篇关于如何在WPF APP中更改ToolBarPanel的边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 10:40