WPF TreeViewItem Style individual borders - wpf

I need to create 3 styles for the items in a TreeView:
Style1 should show a border at the top of the item (full line, not only this item's content width)
Style2 should have no border, but a Red background (this is done already)
Style3 should show a border at the bottom of the item
The styles will be assigned in code behind according to some situation.
How do I define the borders in these styles?
Thank you!

Related

Removing border on ListViewItem

I would like to remove the border which is between the border of ListView and ListViewItem which looks like it is a border of LVItem.
I really need to get rid of it, since I wanna the selected item to be connected with the right lightgray area. (Sure without that white border which was only testing border, to see whats going on with those borders in listview)
This is my styling code:
http://pastebin.com/TH83CaL0
And my listview xaml code looks like this:
http://pastebin.com/zvyJem02
Edit:
I am newbie with wpf and xaml, since I started with 1 week ago.
I think you can't get rid of this border only by Styling, but you could move the "right lightgray area" a little to the left and let it overlap your ListView by setting Margin="-1.5 0 0 0" Panel.ZIndex="1" or (as you did) hide a little of the ListBox behind the gray area by setting its Margin="-1".

Adding glass effect to listbox item

I have a stackpanel with a background image. Inside the stackpanel there is a ListBox and its background is set to transparent, what I need is to blur (glass effect) the background image only the part that comes under the listbox item. I tried to add a rectangle to transparent color in the listbox item template and then added a blurred effect but it doesn't work. This is what I am trying to achieve.
I came across this some time ago, maybe will help with what you're after.

WPF, ShowGridLines equivalent for wrap panel

I need to display a 1 pixel wide border around all wrap panel cells, kinda like excel grid. Unfortunately the wrap panel does not implement the grid ShowGridLines property. I can't put a border inside every cell because adjacent cells will have a 2 pixel border instead of 1 pixel.
Since the wrap panel arranges it's layout dynamically and does not expose it's properties I can't evaluate the correct value for a border inside a cell. Any workaround possible?
There is no way to show grid lines because it's just not a grid. Even in a WPF grid control, you have very little control over the appearance of lines: How can I change the color of the gridlines of a Grid in WPF?. They're really just for debugging. The workaround is to put a border inside each cell that only has thickness on the bottom and on the right: BorderThickness="0,0,1,1"

adjust border on one specific side

I'm using a controlTemplate of the ListBox to show a collection.
I want to display all the items with a border like in a grid (all lines same size).
When I give every listBoxItem a border, the line between 2 items has a double size.
(made from the bottom border of the first item, and the top border of the second item)
So the question is:
Can I set/hide the border on a single side of an item? (like 'border-top' in css)
The border property is a thickness, just like margin and padding, so you can do Border="2,0,2,2" to get a border of 2 everywhere except the top.

WinForms: color DataGridView border

How can I change the color of a DataGridView border when BorderStyle = FixedSingle?
You cannot change the border color, it is system defined.
Instead you could try turning off the border setting and then placing the DataGridView inside a Panel. Where the DataGridView is set to Dock.Fill and the Panel has a Padding of 1 pixel on all edges. Then setting the background color of the Panel will show as a border around the contained DataGridView.
this.dataGridView1.GridColor = Color.BlueViolet;
source: http://msdn.microsoft.com/en-us/library/ehz9ksfa.aspx
You could change the border if you make your own DataGridView and override the OnPaint() method. Be sure to call base.OnPaint(e) before you do your own magic.
Also, you could add a property "GridBorderColor" which set color, your own painting would use.

Resources