With visual styles, i can use
VisualStyleElement.TreeView.Glyph.Closed
and VisualStyleRenderer to draw [+] button like in TreeView.
But when user have a "Classic" style in Windows, visual styles are not supported and I still need to draw this glyph.
It is still possible to use classes like
System.Windows.Forms.CheckBoxRenderer
but I haven't found anything like this for TreeView glyphs.
Yes, it is not possible to get that glyph. It is a simple one but you have to write the code. DrawRectangle and DrawLine. Or use a bitmap. Or make it look like the simple Vista triangles. Or don't enable ownerdraw when visual styles are off.
Related
In WPF XAML, WindowStyle can be None, SingleBorderWindow, ThreeDBorderWindow, ToolWindow.
I tried the options myself and also looked into MSDN, yet I cannot tell any difference visually between ThreeDBorderWindow and SingleBorderWindow. The "ThreeDBorder" looks just as 2-D as SingelBorder. What are their difference?
You have to switch to Windows Classic theme to see the difference. If you are using a "modern" theme like Windows 7 there is no difference.
Below you have the SingleBorderWindow to the left and ThreeDBorderWindow to the right when using Windows Classic theme on my computer. (The innermost gray border is from a control in the window and is not part of the window border.)
The "3D" border has an inside highlight that I guess gives it a raised or three dimensional look.
So the new WPF 4 text rendering looks great, but enabling the aero glass effect on a window requires that you change the background to transparent, which of course disables ClearType rendering.
Using the provided RenderOptions.ClearTypeHint=Enabled allows you to designate child elements to reenable ClearType rendering from that point in the tree. I've found a few other topics that talk about doing this for the ScrollViewer used internally inside RichTextBox and FlowDocumentScrollViewer, and creating a custom style does indeed fix it so that my FlowDocument gets ClearType rendering again.
However, this only applies to top level paragraphs in the FlowDocument. If I add floaters or figures, or a table, any text inside them is inexplicably grayscale again. I know that the glass effect is to blame, since disabling it reenables the ClearType rendering.
I looked through the visual tree with Snoop, but both the main content (which renders properly) and the sub-content (which is grayscale) have similar element hierarchies without anything to which I can attach RenderOptions.ClearTypeHint.
Has anyone run into this problem? Is there a workaround or a solution? I checked Connect but there isn't any bug filed about this. It's quite an annoying problem.
After doing a lot more research, and comparing the way different controls work on and off of aero glass, I've found a few answers. The TextBox control doesn't work properly either, but portions of FlowDocument and things like TextBlock do, which prompted me to explore why.
After digging around in reflector for a while, I found that when using the advanced text formatting APIs to get text and render it onto a drawing context, the RenderOption flags essentially go ignored, since the drawing system knows from the root visual (the window) that transparency was enabled. Once that happens, all the RenderOptions flags in the world aren't going to get ClearType back.
I did happen to stumble on a work-around though. If you have access to the DrawingContext and are doing the low-level text rendering yourself, you can do a DrawRectangle behind the text with a fill, and ClearType gets reenabled. I assume that this is the only way for the renderer to be sure that it has a proper background to draw on.
So in summary, you need to do your own text drawing, and additionally you need to explicitly draw a background using the same DrawingContext behind your text in order for ClearType to get rendered properly.
I know this could get tedious, but have you tried setting general styles like so:
<Style TargetType="Paragraph">
<Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
</Style>
I really like the Dark Expression theme for the Visual Studio 2010 Color Theme Editor, apart from a few things here and there.
One example is that certain UI elements (such as e.g. Smart Tags) are almost unreadable because they have dark text on dark backgrounds.
I know that I can use the Customize Colors dialog(!) box to edit the colors, but how do I figure out which color to edit?
There's a lot of colors, and it's not very apparent which ones control which UI elements. Is there any way to figure that out?
you can snoop Visual Studio to find out more information about the colors used etc. With Snoop you can even change the colors and look at the results instantly!
So you can just read out wich color is used on wich place and then search the color by name.
I'm looking for a dockable windows/panel control in the style of iGoogle. All of the ones I have found so far all have a fixed length on the height of your window/panel but I want to be able to have windows of varying length like iGoogle.
The best I have found so far has been a control libarary called BlackLight which does not have the feature explained above.
have you seen this docking library:
http://www.codeproject.com/KB/WPF/WPFdockinglib.aspx
I'm using DwmExtendFrameIntoClientArea in my WPF application to get the glass effect. This is working fine. What I'd like to do is change the colour used for the glass -- I'm writing a countdown timer, and I'd like the window to be the normal glass colour most of the time, and then to go red (but still with glass) when the time runs out.
I found this question, which talks about how to apply a gradient glass, and that works fine when picking a different colour. Unfortunately, the borders are not coloured appropriately.
When I turn off the borders by using ResizeMode="NoResize", then I end up with square corners. I'd like to keep the rounded corners.
I looked at creating an irregularly-shaped window, by using AllowTransparency="True" and that works fine, but doesn't look like an Aero glass window. It looks a bit flat.
So: my question: how do I create a window in WPF that looks like Aero glass transparency, but uses a different colour?
I think the only possible way to achieve this is to use a semi-transparent filled border and draw it over the entire window or the part you got the glass. Its a workaround but I guess it's a possible solution since the color of the glass gets defined by the system-user and this setting would overwrite yours.
I'm asking the same question myself.
I haven't found a good solution, though the best I've come across so far is doing the following:
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.FromArgb(100,255,0,0);
Unfortunately this tints the minimize, resize and close buttons, which I would rather avoid.