Russ Suter
asked on
Xaml: How do I create a background that looks like alternating grid rows?
I'm still learning so much about Xaml but one thing I currently need is a background that looks like alternating colors of grid rows like this:
I'm reasonably sure I'd use a VisualBrush element to do this but I honestly have no idea how to construct the thing. I need a thin border between each "row" and every alternate "row" needs a different color.
I'm reasonably sure I'd use a VisualBrush element to do this but I honestly have no idea how to construct the thing. I need a thin border between each "row" and every alternate "row" needs a different color.
ASKER
That wasn't nearly as difficult as I thought it would be. I see now that a visual brush is just basically anything you can draw using Xaml. That last example is pretty much what I need. I just need to tweak the height values to make it work for me. Thanks.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
<DataGrid AlternatingRowBackground="
...and you can use the RowStyle to set a border on each row (placed inside the <DataGrid> element):
Open in new window
Haven't tested it out yet, but should work in theory.
If you're just looking for a plain, repeating background without any ties to data elements or anything, but that scales in height/size with the element, you can definitely use a VisualBrush, like this:
Open in new window
Or if you don't want it to stretch like that:
Open in new window