can my control have multiple themes by default - silverlight

I have a control and i put its template in generic.xaml.
is it possible to have other themes like:
bluesky.xaml
tealocean.xaml
How would I do this? How would the themes get changed?

The best currently available way is to use Theme control from a silverlight control toolkit to dynamically change themes.
Here is an article on this: http://weblogs.asp.net/lduveau/archive/2010/05/31/dynamically-apply-and-change-theme-with-the-silverlight-toolkit.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 WPF themes get loaded?

WPF controls get their default styles, colors and brushes from a theme (Usually, in PresentationFramework.Aero.dll).
What piece of loads this assembly? And where are the resource dictionary stored?
I have my own WPF custom themes and load them in the Application.Current.Resources.MergedDictionary.
However, this does not work if the WPF themed control is hosted in Windows Forms since Application.Current is null.
Is there a way to do something similar to what WPF does? If so, what is it?
You cannot use the WPF themes in Winforms because they are two different technologies. There isn't a similar theme mechanism in Winforms natively. You can use third-party controls that support themes in Winforms. The most notable of these are the tools from Infragistics and Telerik.
Bottom line answer is no, there isn't.
Can you try just adding the theme to the control instead of the Application?
control.Resources.MergedDictionaries.Clear();
control.Resources.MergedDictionaries.Add(resourceDictionary);
(answering my own question)
The way to load a resource dictionary as a theme is to add it to the list of merged dictionaries of the generic.xaml resource dictionary.
There is no other way to load a resource dictionary as a theme.
This works fine when used from WinForms

How to style the thumb of wpf slider?

I read about style here:
http://msdn.microsoft.com/en-us/library/cc278073(v=VS.95).aspx
I created a UserControl with slider and UserControl.Resources section. I paste the thumb style but some tag are not recognized like vsm:VisualStateManager (I'm using VS2010) why ?
That is the documentation for Silverlight. You probably want the documentation for WPF:
Slider Styles and Templates
Edit:
Just to be clear, if you are using Silverlight, you should use Silverlight templates and styles; if you are using WPF, you should use WPF templates and styles.
In any case, the VisualStateManager is a full-fledged part of both Silverlight4 and WPF4, so if you see a template with the "vsm:" namespace, the simplest option is to just remove the prefix where-ever you see it.

Silverlight Bing Maps Pushpin Styling

Does anyone know if the default control template and XAML style is available anywhere for the Bing Maps Silverlight controls? We like the general appearance of the default Pushpin control, but want to have them available in multiple colors, not just the default orange. It seems the only easy or straight-forward way to do this would be to provide a new ControlTemplate based off the default -- one for each color -- in our App.xaml.
Not a problem, except that I have been unable to identify the existing default control template. Most of the core Silverlight toolkit controls have their default styles available on MSDN, but I haven't found the ones for the Bing Maps API.
Thanks,
Jeff
Just set the Background property to change color

Adjust a Control Template and still respect the Theme of the OS?

In WPF how do I modifiy the template for a standard control in a way that it will respect the current Theme of the Operating System later on? If I just "edit a copy" of the template in blend, it will just give me the template of the currently running theme. Is this correct? So when I apply the modified template and run the app on different themes it will always look the same.
For custom controls and even for data templates the problem is similar. How do I provide a template that respects all possible themes of the OS?
I don't think this is possible. If you create a template for a control you are replacing the entire control template.
You can use styles to just configure exposed properties, but if you change the template, you are no longer related to the theme. You can create a separate override of the template for each theme, but you would have to define each explicitly and if Microsoft created a new theme you would have to create a new template to match it.
See my own related question - When overriding WPF templates do I have to override each theme’s template separately?

Resources