How to get "native" look for WPF widgets on windows XP? - wpf

I have just started playing around with WPF.
I've noticed that while some widgets automatically pick up the native look and feel (e.g, buttons, menus), some others don't (e.g., labels, panels and windows have white backgrounds).
How do I make all widgets look normal by default in WPF?

This is the way the templates are defined in the PresentationFramework.Luna assembly. You can look at all of the default templates for all 6 Windows themes by using the ShowMeTheTemplate tool found here: http://www.sellsbrothers.com/tools/#ShowMeTheTemplate
-Jon

Related

How can I make a stack panel with a transparent background and blur effect in WPF without an image?

I have only found solutions to this question that work with images, but I want to be able to overlook a stack panel with this "effect", for example. I actually want it to look something like the one in Windows, for example, like here:
so that you can see a slight transparency in the background.
This kind of translucent texture is called Acrylic and is a Fluent Design System component on Windows 10.
If you want to bring this kind of brush to your app, I would recommend you to look into using the WinUI library. This is the modern and native user experience (UX) framework for Windows desktop applications going forward.
WinUI 2.x controls be used WPF applications using XAML Islands.
WinUI 3 is the next version of WinUI that includes a full native UI platform that can be used on top of the latest version of .NET and be seen as a replacement for WPF and WinForms GUIs.
There is no native support for Acrylic in WPF.

How do I apply the current Windows theme in my WPF application?

I am working on an WPF application. WPF allows me to style everything but I just want my app to have the same theme as the other Windows applications. I want it to use the current Windows theme. Is this possible?
Whilst you're doing your styling you will be using brushes and colors.
If you want your styling to conform to the windows theme then you should ensure all your brushes and colors used are based on SystemColors.
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/how-to-paint-an-area-with-a-system-brush?view=netframeworkdesktop-4.8
https://learn.microsoft.com/en-us/dotnet/api/system.windows.systemcolors?view=netcore-3.1
You will find that a number of the default templates do not do this and instead have "hard coded" colors. Hence you will have to provide your own replacement templates for all these.
Unless you have extensive experience of wpf templating you are likely under estimating the amount of work which will be involved.
This is a lot of work.
If you look at custom themes which are available you'll often find the author missed some subtle aspects of controls here and there.

dragable controls in runtime Similar to a toolbox in wpf

I want to create a project in WPF for designing a custom report.
For this, I need a library to add controls to a panel, canvas, etc. with drag and drop at runtime.
Controls should be resizable and moveable with the mouse. Finally I want to print this.
Telerik's WPF controls contain the Diagram Control which supports the features you mention out of the box. I use it for a very similar scenario as you describe and it works well. The might be a counterpart offered by Infragistics as well.
With .NET framework's built in features and/or free libraries you will able to cover the drag&drop part. You will have to implement the rest yourself which is possible but too much to ask for one question.
Late reply, but I came across this. Take a look at this
There are 4 parts that show how to do a toolbox with what you're looking for.

Is there a document highlighting WPF and Silverlight controls available in the framework?

I'm looking for something like a pdf or anything else that would show a chart of available controls in SL and/or WPF.
Ideally, the chart should have a drawing of the control, some succinct description and the hierarchy if possible.
Has anyone seen such a thing? Freeware or Payware, can even be from a book I could buy.
The following MSDN link lists the controls within the Silverlight SDK:
http://msdn.microsoft.com/en-us/library/cc189048(VS.95).aspx
You can try the sdk controls live following this link:
http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/#/?sref=HomePage
The controls within the Silverlight Toolkit can be found here:
http://silverlight.codeplex.com/
Also, there are plenty of third party controls for Silverlight. The following link contains a list to some of them (free or not):
http://timheuer.com/blog/archive/2009/01/28/comprehensive-list-of-silverlight-controls.aspx
The controls that are shipped with the platform are fairly straightforward, so I'm not sure that would even make sense - i.e. the basic buttons, input box, text block, etc.
As for the controls that are shipped with the Toolkit, which is the richer feature set released out of band in relation to the Silverlight trunk, you can preview everything you asked for here:
http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html
What's more, the source code for the preview is included with the tool kit so it's very easy to see how any of those controls were used.

Menu Format is different in Windows 7 vs Windows XP for a Winforms app

I have a Winforms app that was originally created in vs 2005 and that was converted to vs 2008. When running this app in Windows 7, the menus don't look like the standard menus in Windows 7 (i.e., the formatting for the menu items is different than the formatting for other applications). This applies to menus displayed on the menu bar of the application as well as the right-click context menus. FYI, I am using the System.Windows.Forms.MenuStrip and the System.Windows.Forms.ContextMenuStrip controls.
Does anyone know why the menus aren't rendering with the default Windows 7 look and feel?
MenuStrip uses a custom renderer, it doesn't leave it up to Windows to draw the menu. You can change the RenderMode property to System but that doesn't help, it's a pre-Win7 version of what system-drawn menus looked like. If you want Windows to render the menu then you'll have to fall back to the .NET 1.1 MainMenu component. Another way is to assign the Renderer property to your own custom renderer, not really practical.
This is also an issue with WPF, worse because it renders all the controls itself. We are quickly approaching a stage where the look-and-feel of a program is determined by the UI class library, not the operating system.
If you have any OWNERDRAW items in your menus, Windows 7 will revert to a backward compatible drawing mode to avoid breaking your code. Do you override the drawing of any of the items?

Resources