如何在wpf中添加没有阴影效果的边框线

时间:2013-09-20 07:09:27

标签: wpf wpf-controls wpf-4.0

where tree view border is not with single line but with shadow effect

上面的树视图在左上角和左上角看阴影效果。我需要一条粗线。

我的xaml是

       Margin="0,0,0,2"  BorderBrush="Black"  BorderThickness="1"

我需要一条线但不是一条shodow。你能帮帮我怎么做吗?

2 个答案:

答案 0 :(得分:1)

执行此操作的一种方法是为您的Template创建简单的TreeView,如下所示:

<TreeView BorderBrush="Black" BorderThickness="1" Background="Beige">
   <TreeView.Template>
      <ControlTemplate TargetType="{x:Type TreeView}">
         <Border 
            BorderBrush="{TemplateBinding BorderBrush}" 
            Background="{TemplateBinding Background}" 
            BorderThickness="{TemplateBinding BorderThickness}">
            <ScrollViewer>
               <ItemsPresenter/>
            </ScrollViewer>
         </Border>
      </ControlTemplate>
   </TreeView.Template>
</TreeView>

答案 1 :(得分:0)

您可以尝试这样做以摆脱树视图边框并应用您自己的边框:

 <Border BorderThickness="1" BorderBrush="Black">
        <TreeView BorderBrush="Transparent" BorderThickness="0"

        </TreeView>
</Border>