Should I care about current theme? - wpf

Authoring a WPF control template, consisting of only a Grid, some TextBlocks and a couple of Buttons, do I really need to worry about the current theme on user's machine? Will it look crippled or otherwise imperfect on a machine running on Win8? I do not have access to a Win8 machine, so can't ensure, but this forum post suggests that "simple" controls are not affected by the current theme. If that is the case, which controls are included in the list of simple contorls?

I believe all standard controls come without any styles applied to them on Win8.
Update:
I am sorry it looks like I was wrong. There is a specific Theme for Windows 8. It is called Aero2.NormalColor.xaml
You can find more info about it here:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/e3dd4221-af4d-4ae4-a983-895db12ebcd0/what-is-the-theme-name-for-a-wpf-application-on-windows-8
Here is where to find the theme file itself:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d05228d4-3dc2-4241-84a1-236a7a1f2d65/where-is-the-xaml-source-for-the-aero2normalcolor-theme
More here
http://brianlagunas.com/add-windows-8-aero-theme-support-to-your-wpf-custom-control/
Update 2:
And here is how to force your application to use specific Theme ignoring windows version:
http://www.kennethham.com/wp/2010/11/force-wpf-to-use-windows-7aero-theming-in-classic-mode/

Related

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.

Where to find a free style for my WPF applicaton?

I am not happy with the default style of my application and I'd like to add a style that makes it look more professional. I downloaded some themes but the ones I found kinda ruined my window interfaces.
Any idea where to find free recent WPF styles?
There does not exist anything like this, what you are describing. You can get Windows themes, which will impact your whole OS but also your application if you have been using system colors while developing.
There is no magic formula that would know how to style which button. This is something you have to implement on your own.
What you can do is to learn more about how to properly style an application using styles from from a external . In order to make your application more appealing you can download a color pallet and follow it. The designing you will, still, have to do on your own.
There are themes pre-made available on the internet. : http://brianlagunas.com/free-metro-light-and-dark-themes-for-wpf-and-silverlight-microsoft-controls/
You need to add them to you project.

Changing specific Multilist line UIID programmatically

My problem is that layout of my application does not behave in a same manner on different platforms. etc. On Windows platform fonts are larger than on Android or iOS so I'm trying to fix this programmatically.
In case of MultiButton I used:
if (platformOS.equals("win")) {
findMultiButtonMainMenu1(f).setUIIDLine1("MultiButtonCustom");
}
I dont see that MultiList has method for changing specific line UIID.
Is there a way to change UIID of the specific MultiList line programmatically?
Is this the right way to go or I should try to use a different theme when application is running on Windows platform?
Personally I think its very wrong to use code like:
if (platformOS.equals("win"))
This will litter your code with such hacks. If you want all the OS's to look the same just remove the includeNativeBool from the theme or copy one of the native themes (e.g. the iPhone theme) to get a single look for all platforms.
As to your answer this isn't exposed as an API since the class was mostly designed for the GUI builder but you can call:
list.setPropertyValue("uiid1", "YourUIID");
To do it.

Editing the standard WPF Aero theme

I want to look into the default styles that are used for the default WPF application so that I can experiment/tweak them. (I believe this to be the standard AERO theme)
So I downloaded the default themes from Microsoft, and manually applied the AERO theme.
I added the "Aero.NormalColor.xaml" file into my project
I then added "PresentationUI.dll" and "PresentationFramework.Aero.dll"
I then modified the namespace from "xmlns:theme="clr-namespace:Microsoft.Windows.Themes;" to "xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" (It was throwing errors otherwise)
Finally I add it into the Apps resource dictionary
But it ends up looking slightly different, in particular, menus seem to look different. So I guess I'm running the wrong theme.
This is using VS 2010 and the default new .net4 WPF application project
Those default themes you downloaded could be god knows what. Probably not what is shipped with the actual .NET framework and Windows.
I don't know what your end goal is, but I would suggest looking at the XAML of a specific control you are interested in Blend. It was a pretty simple action, something like right click -> edit control template, although I can't remember the exact steps (like where to click exactly etc). I'm sure you can google that information very quickly...

Why WPF renders differently on different versions of Windows?

I read that WPF uses DirectX under the hood to perform its rendering, that it doesn't rely on the dinosaurian libraries that WinForms uses to render controls.
So I made my Presentation layer with WPF and it looks the way it should under Win8.
Then I deployed the project to Windows Server 2003... to find out that my nice little custom message box looks awfully WinForms-like and somewhat clunky; the button controls are VERY similar to the WinForms ones, the expander control is no longer shown as a circled ^ arrow and looks like it was drawn in 1998 (picture the ^ arrow on an ugly square flat button that pops up when your mouse hovers over it).
From the Pro WPF in C# 2010 Bible:
Part of the promise of WPF is that you don't need to worry about the details and idiosyncrasies of specific hardware. WPF is intelligent enough to use hardware optimizations where possible, but it has a software fallback for everything. So if you run a WPF application on a computer with a legacy video card, the interface will still appear the way you designed it.
So, is this a lie? To me it is, because it doesn't appear the way I designed it.
If not, then why/how doesn't the thing render identically regardless of the machine that's running it? Is the software fallback somehow designed to mimick Win32/GDI rendering? Is there a way to get my little custom message box to look identical on Win8 and WinServer2K3?
That has NOTHING to do with DirectX / Rendering / video card / any of that.
and EVERYTHING to do with WPF taking the DEFAULT appearance of ALL UI Elements from the Windows Theme.
If you don't want this behavior, you'll have to provide Styles and Templates for ALL UI element types, or otherwise find a way to include PresentationFramework.Aero.dll in your application and use that as the default theme library.
Take a look at this answer

Resources