How do I get the native "look and feel" using WPF? - wpf

I've just started developing a WPF application. This is not my first WPF app, but it will be the first that needs some polish. I know quite a bit about the "plumbing" of WPF such as binding, etc., but very little about how to polish it up. I don't need a snazzy UI. I just need something that looks like a native Windows app. For instance, if the app runs on XP, I want it to look like an XP app and pick up the user's UI theme. Same thing on Vista, etc.
How can I do this?

You should be able to put this into the application's OnLoad event to use the Vista theme, for example:
Uri uri = new Uri("PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\\themes/aero.normalcolor.xaml", UriKind.Relative);
Resources.MergedDictionaries.Add(Application.LoadComponent(uri) as ResourceDictionary);
or for the Windows XP theme:
themes/Royale.normalcolor.xaml

You don't have to do anything - WPF does it for you.
EDIT: It does. Run it with Aero/Luna and then Classic.

Related

Steps for change the UI of desktop app from winforms to wpf

I built a small desktop app on c# .net
Local desktop without any internet connection or communication with other any computers, I used winforms.
As expected I split up between logic and UI, and now I want to use WPF to my UI (change the way I implement the UI part), and in the future I will want to use mobile UI..
What are my steps should be?
Do I need to write new code, or there is something automatic?

How can I use transition themes (e.g. EntranceThemeTransition) in WPF?

I created a Universal Windows Application that performed a basic transition between my MainPage and 3 other BasicPages. Each BasicPage had a Grid and I was able to animate the items in the Grid when it was loaded using EntranceThemeTransition in XAML. So good so far. The problem, however, is that I can't run this like a normal Windows application. My understanding is that it must be loaded as a Metro app in order to run. This is problem because I would like to run this program on a Windows 7 machine.
Now I'm re-creating the project in WPF, but I can't use EntranceThemeTransition like I did before. There is no TransitionCollection or EntranceThemeTransition in the XAML for VB.NET.
Is there some way to access this prebuilt transition or will I have to use a combination of DoubleAnimation on the *.Left property *.Opacity property?

AutomationProperties in WPF

Can anyone give an example as to how AutomationProperties.LiveSettings work?
I have been working on a WPF application and I want a Text Block to be made live. In Html its easy to do, but using an aria-live tag, however I have been struggling to do the same in WPF.
AutomationProperties.LiveSetting cannot be used in WPF. It can be used with XAML only for developing windows store app or mobile app. In case of a store/phone app, a different library of AutomationProperties is used which supports the usage of LiveSettings. In case of WPF app, there is a different library of AutomationProperties which doesn't have the LiveSettings property.

how to use ProgressRing in a WPF application for windows

As simple as in the title, I'd like to know how to use a ProgressRing on my gui. I can't figure out how to import the Windows.UI.Xaml.Controls namespace in which seems to be located.
Thanks!
Eugenio
I don't think you can add a reference to a Windows Store Apps DLL to a WPF project, they are built against different versions of the framework.
You could however use a ProgressRing from a different WPF targeting DLL; MahApps Metro has one https://mahapps.com/docs/controls/progressring (source is on github so you can just take what is needed without having to jump fully into the metro style)
Or you could implement your own following a tutorial http://henryzhu1997.wordpress.com/2013/06/18/creating-a-progressring-for-wpf/

Is there something like a QueryUnload event in WPF page-based apps?

I'm working on my first WPF app, using VS 2008. When I worked in VB6, there was a form event called QueryUnload, which one could use to determine how an application was shutting down. I'd like to do the same thing in a page-based WPF application, if that's possible. (My app is not an XBAP application, but a page-based app.) I know that VB6 didn't have anything like a page-based application, so it might not be possible.
You do it in your handler for Window.Closing, see here

Resources