Reputation: 63
Below is the Code , in which i want to change the theme color of the MahApps.Metro pakage.
it can be changed by changing the ResourceDictionary Source pack of MahApps. [/MahApps.Metro;component/Styles/Accents/Blue.xaml ]
say example its /Blue.xaml now ... we can change colors of the window. to /Red.xaml , /Yellow.xaml etc
So how can i change the color of the window asynchronously in every 5 seconds? is this possible in wpf ?
i am new to wpf and clueless.
<controls:MetroWindow x:Class="NginX.Choose"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="NginX" Height="350" Width="350" ShowMaxRestoreButton="False">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
</Grid>
</controls:MetroWindow>
Upvotes: 0
Views: 368
Reputation: 4896
You can replace the Application's resource dictionary by doing:
Application.Current.Resources.Clear()
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml")
});
Put this in a timer and cycle through Red.xaml, Blue.xaml etc
Upvotes: 0