Created
December 22, 2009 20:51
-
-
Save mletterle/262039 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class App : Application | |
{ | |
private static bool _bIsBlackSkin = true; | |
public App() | |
{ | |
Window window = (Window)System.Windows.Markup.XamlReader.Load(new System.IO.FileStream("Window1.xaml", System.IO.FileMode.Open)); | |
System.Windows.Controls.Button button = ((System.Windows.Controls.Button)window.FindName("ToggleSkin")); | |
window.Closed += new EventHandler(window_Closed); | |
button.Click +=new RoutedEventHandler(ToggleSkin_Click); | |
this.Run(window); | |
} | |
void window_Closed(object sender, EventArgs e) | |
{ | |
this.Shutdown(); | |
} | |
private void ToggleSkin_Click(object sender, RoutedEventArgs e) | |
{ | |
var rd = new ResourceDictionary(); | |
string uriSkin; | |
if (_bIsBlackSkin) | |
{ | |
uriSkin = @"Skins\Green\GreenResources.xaml"; | |
} | |
else | |
{ | |
uriSkin = @"Skins\Black\BlackResources.xaml"; | |
} | |
_bIsBlackSkin = !_bIsBlackSkin; | |
rd.MergedDictionaries.Add(Application.LoadComponent(new Uri(uriSkin, UriKind.Relative)) as ResourceDictionary); | |
Application.Current.Resources = rd; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="Window1" Height="300" Width="300" | |
Background="{DynamicResource MainBackgroundBrush}"> | |
<Grid> | |
<Button x:Name="ToggleSkin" Content="Toggle Skin" Margin="30,30,30,30" /> | |
</Grid> | |
</Window> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment