Change WPF control property on one theme only - c#

I know this is a little petty, but... On Windows 7, the default foreground color for ListViewItems is, for whatever reason, dark blue. This confuses and infuriates me. I would like to make my ListViewItems have black text. But if I set my TextBlocks in the DataTemplate to have Foreground="Black", then it looks weird on Windows XP, since the Foreground of the selected item is supposed to be White on XP; with Foreground="Black" it's quite hard to read. Is there some way I can set the Foreground to Black only on the Aero theme and not on the other themes?

What about if someone uses a theme that you have not tested? You cannot control every single theme.
I suggest you to build your own ControlTemplate to achieve your desired visualization. In this way your controls will be displayed in the same way in all situations.

Related

transparent tab control appears white

Anyway, I'm having a little difficulty with tab control. When I drag a new tab control onto a form, it appears white, rather than the grey (system colour) I was expecting.
When I look at the properties, its colour is set to web-transparent. Ok, so it should be transparent then (it isn't letting anything behind it show through). Setting the tab control back colour manually back to the system grey kind of works, but the tabs at the top still show as white. I'm assuming I could somehow change their colour as well, but I'm quickly getting into the realms of changing so many values from default, I'm clearly missing something type territory. I've googled every varient of "transparent tab control draws white" as I can, and although I found something to do with windows profiles, this seemed mostly confined to access 2003 using the vb you got access to in access.
I'm looking for any explanation as to:
what I need to do to correctly use transparency with tab controls
what I'm mis-understanding as the purpose of transparency in tab controls
how to easily change all the colours of the appropriate parts of the tab control to not be transparent.
I'm looking at windows forms for an MCTS, so please don't give a "you should use X instead" type answer.
No, getting white is certainly normal. TabControl and TabPage are rendered with theme colors when visual styles are enabled. So that makes the tab page white on machines with the standard Windows theme.
Yes, the default BackColor of Transparent is very unusual. You most certainly will never get actual transparency with that, unless you count seeing the background of the TabControl as transparency. The logic is pretty convoluted, rather than trying to explain it I'll just paste the MSDN explanation:
The default value of the BackColor property is the value of the Control.DefaultBackColor property unless the UseVisualStyleBackColor and Application.RenderWithVisualStyles property values are both true and the Appearance property of the parent TabControl has a value of Normal, in which case the default value of the BackColor property is Transparent. Child controls that you place on the TabPage inherit the BackColor value by default, so this behavior causes the background of the child controls to render with the current visual style.
Changing the value of the BackColor property automatically sets the UseVisualStyleBackColor property to false. If you want the TabPage background to render using visual styles but you want the child controls to inherit a BackColor value that you specify, set the UseVisualStyleBackColor property after you set the BackColor property.

What system colour property do Windows tooltips use for their background colour by default?

I've got a window I popup that I'd like to style the same as the default Windows tooltip.
What system colour should I be setting the BackColor property to? There isn't a TooltipBackColor in the system colours property tab.
Apologies to Jalal Aldeen Saa'd but I'm already using System.Drawing.SystemColors.Info and this doesn't change from the default dull yellow colour when I change theme, but the tooltip backgrounds do, as you can see in this screen shot:
(It's actually a bug that you can get both the tooltip and the popup visible at the same time)
The windows default is called Info...
EDIT:
If you are in WPF (which supports theming) then according to http://msdn.microsoft.com/de-de/library/system.windows.systemcolors.infocolor%28v=vs.85%29.aspx it is System.Windows.SystemColors.InfoColor
this updates automatically with the chosen theme
EDIT 2- for WinForms:
it is a bit more complicated... you instanciate a System.Windows.Forms.VisualStyles.VisualStyleRenderer with a VisualStyleElement.ToolTip.Standard.Normal and then you can call GetColor on the renderer with System.Windows.Forms.VisualStyles.ColorProperty.FillColor
that gives you the current theme backgoundcolor of a tooltip
System.Drawing.SystemColors.Info
You can get it by new System.Windows.Forms.ToolTip().BackColor

win 7 can't paint combobox

I have my program that paint the backcolor of a combobox column in a datagridview.
I win xp everything works fine, but in win 7 the comboboxes have the gray color:
if you look the shot, you see that the combobox columns are grayed, but they must be yellow like the other columns.
if I use the old windows theme the grid is ok, but I wish use the new themes of win 7.
(i'm the developer, so I can change the code to paint the cell)
Hm, I hope someone comes up with a better solution, surely companies creating custom skins have this problem. There are the two solutions I found, either change the visual style or changing the FlatSyle;
Possible to use XP Visual Style in Vista/Win7?
Need to change DatagridviewCombobox cell background color in Windows7
Although this talks about the ForeColor, it may be also provide a fix for the backcolor;
How to change ForeColor of ComboBox's Selected Item? #Cody Gray
solved, use flat style for the combobox and the color is shown correctly

Background color of VS Package Addin?

this may be a pretty simple question.
I've created a VS Package and it has a nice little GUI. The background of the GUI should be System.Colors.ControlBrush:
<Grid Background="{x:Static SystemColors.ControlBrush}">
Now I have the problem, that it changes the color of the Grid, but not of the rest of the window. -> Screenshot
I thought I could change the background of the UserControl the same way, but somehow it doesn't work. Now it doesn't really look that great, if a part of the window is grey and the rest is white.
Any idea?
Your UserControl is probably not covering the entire window.
Remove any Width or Height attributes and make sure that the Horizontal/Vertical Alignments are both Stretch.

WP7 Trouble customizing DatePicker control

I'm using the DatePicker control from the WP7 SL toolkit. It navigates to DatePickerPage.xaml, which has the scrollers for date picking. I want to keep all the functionality, but change the colors. I'm messing around with DatePickerPage.xaml and updating colors to fit my needs.
I've been able to update the text colors on the scrollers and header, but I can't figure out how to update the background color on the selected item in each or the square outline while the scroller is active. Based on tests I have done with changing the background color of the DatePickerPage.xaml, it appears that the selected item and square outlines are an opaque version of the background color. Unfortunately, this wont work for me, since I want the background to the be white and the outlines aren't visible. Is there a way to explicitly set those colors?
If you get the control into Blend and right click on it and select Edit Tempate --> Edit a Copy, you'll get the template for the control so that you can edit it.
What you'll be looking for is the resources keys that are used for the background, foreground, etc. You can replace them with your own resources, or hardcode them, or the best option is to override the resource.
Additional Advice
Be careful though, don't forget that a user can have either a dark or light background to the phone, so unless your app is taking control of the background color of the whole page, you need to consider what might happen when picking colors

Categories