Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing a WPF ListView's "classic" indented border

How can I remove the "classic" indented border from around my WPF ListView control? Setting its BorderThickness to 0 does not get rid of it.

like image 441
sourcenouveau Avatar asked Oct 13 '09 21:10

sourcenouveau


People also ask

How to remove listview border wpf?

To get rid of the indented border, you will need to find the specific border definition in the control template that is causing the behavior you want to modify; there are several of them, but it should be easy enough to figure out which one is causing the indentation using trial and error and/or Snoop.

How do I add a border in WPF?

To place a border around an element, WPF provides the Border element. Similar to other WPF elements, the Border has Width, Height, Background, and HorizontalAlignment and VerticalAlignment properties. Besides these common properties, Border has two properties that make Border a border.


2 Answers

Don't know if its a former version of WPF, but on Visual studio 2008 the following is enough to remove all borders and colors of a listview control

<ListView Background="Transparent" BorderThickness="0">
like image 147
Nikos Tsokos Avatar answered Oct 15 '22 22:10

Nikos Tsokos


For a lot of the built-in WPF control styles, you need to override the ControlTemplate to get this level of control over the rendering.

Here is the MSDN page that provides the ListView ControlTemplate, with instructions on how to use it -- basically you are inserting local copies of all the styles for the ListView control, which then override the default control look and feel.

To get rid of the indented border, you will need to find the specific border definition in the control template that is causing the behavior you want to modify; there are several of them, but it should be easy enough to figure out which one is causing the indentation using trial and error and/or Snoop.

like image 20
Guy Starbuck Avatar answered Oct 15 '22 21:10

Guy Starbuck