Answered by:
Changing App Skin at Runtime C#

Question
-
I want to Changing App Skin at Runtime but isn't Right, please ,how can i do it?
- Edited by 楚萧萧 Thursday, November 21, 2013 8:59 AM
Thursday, November 21, 2013 8:57 AM
Answers
-
use bindings ?
Microsoft Certified Solutions Developer - Windows Store Apps Using C#
- Marked as answer by 楚萧萧 Friday, November 22, 2013 3:01 AM
Thursday, November 21, 2013 9:34 AM
All replies
-
use bindings ?
Microsoft Certified Solutions Developer - Windows Store Apps Using C#
- Marked as answer by 楚萧萧 Friday, November 22, 2013 3:01 AM
Thursday, November 21, 2013 9:34 AM -
private void BtnChangeSkin_Click(object sender, RoutedEventArgs e) { ResourceDictionary dict = new ResourceDictionary(); var rd = Application.Current.Resources.MergedDictionaries.First(); String old = rd.Source.AbsoluteUri; if (old == "ms-resource:/Files/Skin/RedSkin.xaml") { dict.Source = new Uri("ms-resource:/Files/Skin/BlackSkin.xaml"); } else { dict.Source = new Uri("ms-resource:/Files//Skin//RedSkin.xaml"); } rd = dict; Application.LoadComponent(this, new Uri("ms-appx:/MainPage.xaml", UriKind.Absolute)); }
BlackSkin.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="SkinButtonStyle" TargetType="ButtonBase" > <Setter Property="Foreground" Value="White"/> <Setter Property="Background" Value="Black"></Setter> </Style> <Style x:Key="SkinTextboxStyle" TargetType="TextBox"> <Setter Property="Foreground" Value="White"/> <Setter Property="Background" Value="Black" /> <Setter Property="Text" Value="hello" /> </Style> </ResourceDictionary>
RedSkin.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="SkinButtonStyle" TargetType="ButtonBase" > <Setter Property="Foreground" Value="White"/> <Setter Property="Background" Value="Red"></Setter> </Style> <Style x:Key="SkinTextboxStyle" TargetType="TextBox"> <Setter Property="Foreground" Value="White"/> <Setter Property="Background" Value="Red" /> <Setter Property="Text" Value="大家好" /> </Style> </ResourceDictionary>
this is the code ?how to ues binding?think you very much!- Edited by 楚萧萧 Thursday, November 21, 2013 9:54 AM
Thursday, November 21, 2013 9:51 AM -
It's right now ,think you everyone.Friday, November 22, 2013 3:01 AM