Editing the standard WPF Aero theme - wpf

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...

Related

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.

Should I care about current theme?

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/

Strange Design Problems With Infragistics Controls

I'm working on an existing WinForms application and I am having some weird issues with Infragistics controls in a WinForms app.
When I open a form or usercontrol in the project that has Infragistics controls on it, it looks like
this http://sdrv.ms/S7gvmS
I cannot access any of the controls in the design surface. Clicking does nothing. And, all of the controls appear in the lower area.
So I created a new test solution and dropped some Infragisstics controls on and got this http://sdrv.ms/SRdo2y
Anyone know what's going on?
When I've run in to similar issues before it's tended to be a license or version problem, the Infragistics libraries contain code stopping them working at design-time if a valid license isn't installed. To resolve this, I'd first recommend deleting all of the *.licx files in your solution. These can be easily corrupted especially if you're using source control and should be regenerated correctly when you go in at design time. If that fails, then I'd try uninstalling and reinstalling Infragistics ensuring the version installed matches those of your projects' reference.
P.S. Realise this is far too late to help the original poster but hopefully will help people coming across similar issues in the future.
This happens when Visual Studio cannot find the Design assembly. The components refer to a designer and if Visual Studio cannot find the designer, it makes the assumption that the object is a component instead of a control and places it in the system tray.
Typically, this indicates that something when wrong with your installation of the components, so the usual solution is to re-install.

Toolbar Icons usage in Visual Studio 2010 Express

I am porting a Linux Mono/GTK application to MS.NET/WPF. The application uses a toolbar, which I could have sworn VS had built in support for adding icons to through the WYSIWYG designer.
However, firstly, in the "Items" property, the add button is greyed out. I did some research and found that I could add <Button></Button> tags directly to the XAML, however, I still couldn't figure out how to add icons. I'd like to use the default Windows icons.
I then found that you had to add <Image></Image> tags to create typical icon based toolbar items, however, I didn't know where to find the default windows icons.
I read on a different stack exchange post that they are available in C:\Program Files\Microsoft Visual Studio 10.0\Common7\VS2010ImageLibrary\1033\VS2010ImageLibrary.zip
However, I am stuck with VS Express edition, and according to the MSDN website this archive doesn't exist in VSE.
My question is this: is there any way to use the default Windows icons?
Also, is it possible I've missed something? How do most people handle toolbars?
All the system icons are not saved in the same place. They are spread across multiple dlls.
List of Windows 7 icons stored in imageres.dll is one such place. You can google for other stuff.
One you have the dll from which you want to create the WPF Image you can use Imaging.CreateBitmapSourceFromHIcon function after using LoadIcon

Final steps in using MVVM to decouple GUI from business logic?

Just recently, I learned about using MVVM to decouple GUIs from the underlying model. I ended up learning as much as I could to convert my current application over to MVVM, and was largely successful. Now I need to figure out how to actually take a GUI generated in Blend and use it in place of my current GUI, which was designed in Visual Studio. I can't find any resources on the web for making this as seamless as possible. I'd like to know what you all have done and have had work for you.
My ultimate solution would be something that would allow me to, at runtime, select a skin from a menu and immediately have the GUI change from the current one to another that the user selects. Can anyone point me to posts that explain how to do this?
My current goal is less ambitious -- I'd like to be able to add my new Blend GUI into my Visual Studio project and when I compile, have the new Blend GUI appear. If I want to go back to the old GUI, I would have to recompile. For now, that is okay.
I've got my Blend project added to my VS2008 solution, and have set it to be the startup application. That works fine -- if I run the app, my new GUI appears instead of the old one. The problem now is that it needs DLLs that are actually in a different folder -- the bin\Debug folder of the original startup application. Am I supposed to leave my original GUI as the startup application, and then have its App codebehind load the other GUI?
Also, each of the respective GUIs needs a reference to the ViewModel. In my case, I was just instantiating it in my current GUI class. For the Blend GUI, I instantiated one there as well, since only one of the GUIs will be active. Is this where something like the Unity framework should be used?
Sorry about all of the possibly-incoherent questions, but I'm not quite sure how I should proceed from here. I feel like I'm so close to proving to myself that MVVM is the way to go from a GUI standpoint (I'm already sold on the testability bit).
All the examples I've seen dynamically switch GUI appearance by using some form of ResourceDictionary swapping. A few links:
Load XAML Resource Dictionaries at Runtime
WPF change theme/style at runtime
Hope that helps.
I found a mistake, where in one part of my code I was using the wrong property to get at the currently-running assembly's path. I am now using
System.Reflection.Assembly.GetExecutingAssembly().Location
Although this does work, it only works if I copy the exe from the Blend project's bin\Debug folder into my main application's bin\Debug folder. I will have to live with this by using a post-build event, I guess. I was so spoiled for the past several months working with .NET, where I didn't have to do this (like before in C++) because all of the referenced assemblies get automatically copied over. If I want to debug any code-behind, I also have to set the starting executable in the Blend project's settings, which is inconvenient as well, especially when working on different computers where the paths aren't set up the same. Any suggestions here would also be appreciated!

Resources