Wood with WPF with rounded corners

I have a tree in the user interface with rounded corners, so I need the tree structure to fit. Is it possible in xaml to change the border of a tree to have rounded corners?

I thought about hiding the border and putting a tree structure inside a rounded rectangle, but it loses real estate and seems elegant.

Any ideas?

+3
source share
1 answer

Cancel the control template for the tree to change the border. If you have Expression Blend, you can easily extract the default control template, and then you can just tickle the corresponding radius at the very top border.

MSDN, treeview:

<Style x:Key="{x:Type TreeView}" TargetType="TreeView">
  <Setter Property="OverridesDefaultStyle" Value="True" />
  <Setter Property="SnapsToDevicePixels" Value="True" />
  <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
  <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="TreeView">
        <Border 
          Name="Border" 
          CornerRadius="1" 
          Background="{StaticResource WindowBackgroundBrush}"
          BorderBrush="{StaticResource SolidBorderBrush}"
          BorderThickness="1" >
          <ScrollViewer 
            Focusable="False"
            CanContentScroll="False"
            Padding="4">
            <ItemsPresenter/>
          </ScrollViewer>
        </Border>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

, , , .

+4

Source: https://habr.com/ru/post/1738524/


All Articles