transparent tab control appears white - c#

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.

Related

How do I change the color of the border of fields?

In the designer, the boundaries of the fields are drawn.
When I click the program, the borders are not drawn.
How to make that when you run the program, the borders of the fields were drawn?
Searching the DevExpress support site is always the best first option.
I found this on there. As it states not all skins support this and the default skin I was using "DevExpress Style" didn't. Changing skin to "Darkroom" did.
To display layout borders, set the LayoutControl.OptionsView.DrawItemBorders Property to true and the LayoutControl.OptionsView.ItemBorderColor Property to a necessary color. Note that in specific skins, borders for layout items are not supported, so you need to either set the AllowItemSkinning option in supported skins to true or change LookAndFeel.Style to another style; e.g., LookAndFeelStyle.Flat. If you do not want to affect the look and feel of embedded controls, set the LayoutControl.OptionsView.ShareLookAndFeelWithChildren Property to false.

How to set "keyboard tab borders" not to cover the rest of the UI?

I'm working on a UWP app and I'm having some trouble with the visual states of some UI controls, specifically with buttons and toggle buttons.
Basically, I'd like the borders that become visible when you press the TAB key (to navigate using the keyboard) to have the same ZIndex of the rest of the control, ie. if part of the control is covered, they should be covered too in the same way. But, it looks like these borders are always displayed on top of the UI, no matter what. Here's a screen:
You can see the border going over the rest of the UI, while the rest of that toggle button is correctly covered. The same happens for buttons as well (not only toggle buttons), see here:
I've looked at the template for these controls, but I couldn't find anything related to these specific borders, nor to anything like an explicit Canvas.ZIndex setting or something like that.
I guess this behavior is on purpose, but is there a way to change this and make those borders behave like the rest of the UI?
Thanks!
EDIT: here you can see how a reveal highlight effect is correctly covered by the shadow and the other UI elements on the right, but the TAB border ignores that and is displayed on top of them.
I have noticed similar behavior was previously present in the Start menu as well (although it wasn't with focus border, but with the reveal effect clearly "continuing" into the cut-off portion of the button.
One workaround that comes to mind is to observe the state of the SplitView and when it is closed to actually change the width of the buttons (for example via a StateTrigger). This way the button's area will no longer be "hidden" and the focus border will work properly, as the buttons will end where they should.

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

Transparent LinkLabel over TabControl

I would like to put a LinkLabel with a transparent background over a TabControl. The tab control has NO tabpage.
As it's not possible to add controls other than TabPages to a TabControl, what I do it add the LinkLabel to the control that contains the TabCOntrol, and then use BringToFront on the LinkLabel. This displays it over the TabControl.
Problem: The LinkLabel displays as transparent (BackColor Property), but instead of showing the TabControl's colour as background, it shows the background colour of it's parent, the control that also contains the TabControl.
From what I understand, this is normal behaviour as a Transparent BackColor means that it'll just take the parent's colour.
Question: Is there any solution to display my LinkLabel with the TabControl's background colour?
Thanks
I may be wrong about this, but I think that if you change the LinkLabel's BackColor property in code (e.g. in your form's Load event, as opposed to just setting it in the designer) to match the color of your TabControl, it will work the way you want it to.
Thanks for your answers. I'm now get what you meant.
Using the tab Control's BackColor won't work, because this property always returns the ColorSystemColors.Control, which is greyish. However, when using visual styles (e.g. XP's default theme), the TabControl's back colour is kind of white. I cannot use white either as the tab control is not pure white, but gradient white...

How do I get the actual value of a DependancyProperty?

I have a small UserControl and it needs to know the Background Brush of the control on which it's being rendered.
However, if I look in the Background property of the UserControl it comes back null.
If I call GetValue(UserControl.BackgroundProperty) it also returns null even though up the Visual tree it is definitely being set.
Seems like I must be missing something pretty obvious as it's can't be that hard to figure out the background colour of a control.
It seems to me that your UserControl does not have a background color defined - null means transparent, which is why the parent control's background is visible at all.
It is still the background color of the parent control - the fact that your control does not have its own background color does not mean that it takes the color from the parent control. The "background" of your control will simply show whatever is behind your control.
The background property is not inherited from the parent, you have to set it yourself.

Categories