Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic change theme dynamically (Read 1882 times)
bink
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 18
Joined: Oct 28th, 2010
change theme dynamically
Dec 2nd, 2010 at 6:57am
Print Post  
Hi Stoyan,

Im experimenting a solution to change the style of diagram dynamically,  but got a prolbem now.

The solution Im trying to apply is similar to : http://weblogs.asp.net/lduveau/archive/2010/05/31/dynamically-apply-and-change-t...

I wrapped the diagram inside a theme, and then change the uri of the theme at runtime.

The issue it doesn't seemed work for the custom diagram nodes.  If the Generic.xaml exist, it will take the style of the styles in Generic.xaml.  Otherwise, if I delete the Generic.xaml, there won't be any style at all for the custom nodes.  The styles in the theme is not getting loaded.

Could you provide me a small project that 1) has a custom node with custom style. 2) can change style of custom node dynamically( in a combobox or context menu)? 


Thanks and regards,

Bill
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: change theme dynamically
Reply #1 - Dec 2nd, 2010 at 12:42pm
Print Post  
Hi Bill,

This sample shows one possible solution:
https://mindfusion.eu/_samples/ThemingCustomNodes_Sample.zip.

You can switch between different styles with the ComboBox.

Different styles are grouped in ResourceDictionaries in the /Assets subfolder. Swapping of the current theme is done in the ComboBox_SelectionChanged handler.

You should clear previously set local values by calling the DependencyObject.ClearValue method before applying the new style, e.g:
Code
Select All
diagram.ClearValue(BackgroundProperty);
foreach (var node in diagram.Nodes)
{
    node.ClearValue(BackgroundProperty);
    node.ClearValue(ForegroundProperty);
}
 



I hope this helps,
Lyubo
  
Back to top
 
IP Logged
 
bink
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 18
Joined: Oct 28th, 2010
Re: change theme dynamically
Reply #2 - Dec 10th, 2010 at 2:58am
Print Post  
thx. this is exactly what I want.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint