0

I've got an area (control of type Border) on my window with content that relates to the selected object in a nearby GridView within a ListView.

I want the style of that area to match the style (borders and gradients) of the selected ListViewItem. The look will depend on the user's operating system and its theme.

How do I give my box the same look as a list item?

Mock-up:

enter image description here

Zack Peterson
  • 56,055
  • 78
  • 209
  • 280
  • 1
    Get the [default templates](http://stackoverflow.com/questions/1559261/control-template-for-existing-controls-in-wpf), look at how it's done, take what you need. – H.B. Apr 03 '12 at 01:01

1 Answers1

1

I don't think I fully understand but my guess is that you are talking about the default ListBox selection brush?

That resource is called

{x:Static SystemColors.HighlightBrushKey}

That is the Blue background you show in your mock up. If you want to also set the foreground color that is:

{x:Static SystemColors.HighlightTextBrushKey}

Those two resources will give the system setting for the given user / OS / theme for selection. Is that what you are after?

Brad Cunningham
  • 6,402
  • 1
  • 32
  • 39
  • What about the borders and gradient? – Zack Peterson Mar 29 '12 at 15:55
  • Well the mock you show looks like it is actually using the Focused Button style to get that gradient and the 1px border. Which is NOT the same thing as the HighlightBrushKey. So if you actually do have the style you show in your mock up then the ListBox selection brushes have been customized and you would have to use those resources on the Border element on the right. The background of a border can be a gradient brush which and then set the BorderBrush to get the 1px line around the outside. Does that make sense? – Brad Cunningham Mar 29 '12 at 16:33
  • The mock up shows the default look for a GridView in Windows 7. – Zack Peterson Mar 29 '12 at 17:26