Dynamic Control Styles - wpf

I have a WPF window appliaction that I would like to build the functionality to have a dynamic style (font family, weight, size, etc) that is stored in a SQL database allowing a user to specify the type of style to use on control's such as ListView's and labels, etc.
I have started defining styles in the Application.XAML file and am not sure if this is the best approach to achieve a dynamic style.
My application will give the ability for the user to define particular styles to apply to the controls so I would need the application to be able to update the styles without having to restart the application.
Any advice would be greatly appreciated.
Matt

Yow want something like this -
http://www.codeproject.com/KB/WPF/wpfskins.aspx

Related

Edit WPF styles for a "designer"

We have a designer that did a whole concept of GUI for our next WPF application.
If we are able to provide him a "user friendly" way to edit styles, he would have done it by itself.
He only has to edit colors, and small things like Margin, default fonts, ...
Naturally, I tought that Blend would be the solution, but I admit I'm struggling:
Blend allow us to edit the template, but we don't really want to change the whole template, just some color around. We made a small dummy app that has all the controls required to be themed, we edit template in a dedicated theme file, but I can't find how to have the same template applied to every control(e.g. button) in our application
We use DevExpress as library, and it appears that most of their component are composed of a lot of subcomponent(for which I cannot just right-click then edit template). Plus it seems that the devExpress theme have the priority over the templates changes(tested by changing background colors by example)
As a pure developer I would create a "style" that would be applied on all controls of a specific type in our application, but I can't see how to create and edit them in blend?
What approach would you take?
You want to use DevExpress Theme Editor. It will allow you to edit all used DevExpress themes in your application. It has a friendly UI which should be usable by your designer.
Another approach is probably not so friendly for your designer but you can also manually override DevExpress themes with your extended ones (require XAML). I am not sure about the controls but that way you can for sure modify brushes.

How do I access to the resources in the Fluent Ribbon Control Suite?

I'm developing a WPF application that uses the Fluent Ribbon Control Suite and i'd like to use its 'themes' in the rest of the application.
Specifically, when you choose to use the Blue theme
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2010/Blue.xaml" />
I would like to use some of the colours inside that file, to style other interface elements (buttons, popups etc).
Any idea how I might do this?
You can try this, but it's not ideal…
Downloaded the Source Code from here and open it up in Blend.
Using the Resources tab, browse the different ResourceDictionary file (ColorsBlue.xaml, Button.xaml etc.)
Make a note of the resource keys for the resources you want.
In your original application add the styles/colours etc you want.
Now whenever you change the theme (Blue/Black/Silver etc) it will automatically change the background colour of your controls!
Hope that helps.

WIndows Phone Theme Settings

I'm trying to get my app certified with the light theme for Windows Phone. I'm using a few custom ListBox styles, but I can't figure out why no pivot controls are visible. The foreground and background are both white, so they're invisible. I can't find any implicit or applied styles on the pivot control. TextBlocks have the same problem. From what I've read, the theme settings should be handled by the OS shouldn't they?
You don't need to re-define system resources since those are automatically added to the application at runtime, therefore rendering your ResourceDictionary redundant (and pretty much useless). Try applying the default system styles first. Also, post the XAML so that it is easier to help you fix it.

Resource Dictionaries in a Silverlight Assembly?

I've just begun dabbling in putting together a set of controls as assemblies and I'm working on default styling. What I currently have is a UserControl in a project (thanks Reed!) and I'm able to bring that into another project via reference. I plan to add more controls over time to build something of an SDK.
I currently have some hooks that look for resources in the hosting application which either apply the resources to their respective properties, or style out the control via hard coded defaults.
Is it possible to set up resource dictionaries within the project containing the UserControls so they can use those references as the default, instead of hard coding? If so, how do I target them?
(I have a ResourceDictionary set up within the same project as the controls: Resources>Dictionaries>Colors.xaml)
Thanks in advance!
E
You should really look at creating custom templated controls in library rather than derivatives of UserControls. This will allow projects that reference your library to specify an alternative default style for you controls in the same way as we can for the controls in Microsofts own SDK.
The Creating a New Control by Creating a ControlTemplate topic on MSDN is good starter.
I think this is a better explanation, but i'm trying on a desktop application and i got the same problem.
XamlParseException: Failed to create a 'System.Type' from the text 'local:CustomerEntity'
If I'm undestanding correctly you want to create the file "generic.xaml" in the folder "Themes". However, I don't believe automatic styling works with UserControl only with Control. Generally if you trying to make a control that can be stylized and retemplated you want to inherit from Control and not UserControl.

Does overriding default style/controltemplates break theming?

When I override the default style/controltemplate of a standard WPF control in blend using "Edit a Copy" without modifying it (just creating a local copy of if), will this already break theming in some scenarios? In other words, do different themes provide differnt controltemplate- and/or styledefinitions for the standard controls? How can I make sure that my styles/controltemplates respect theming?
Yes, this breaks theming;
Yes, different themes provide different controls styles. If you have MS Blend you can find them in Blend's folder (e.g. in C:\Program Files\Microsoft Expression\Blend 3\SystemThemes\Wpf )
To respect theming, you should also create one style per theme for your control. There are many resources out there on custom control and themes support. Just to mention one: WPF: Changing control style based on the system theme
As a developer you want to author your controls in terms of their functionality. Use default control styles everywhere. Then let the pro's handle the graphic design aspect of it. If you override a control's ControlTemplate you are busy with theming already.
If you do muck around with ControlTemplates try and keep with the standard approach, otherwise once the graphic designer starts working on the application he/she's going to swear at you :)
Themes are collections of styles that target individual controls and redefine their look-and-feel. Any Control for which you've provided a ControlTemplate will either not have it applied or won't be consistent with the theme-pack (depending on whether you access the theme by x:Name or by Type)
If you override DataTemplates, you are fine however. This you can safely do without worrying about theming interference.

Resources