WEB开发网
开发学院图形图像Flash 使用Silverlight Toolkit中的主题(Theme) 阅读

使用Silverlight Toolkit中的主题(Theme)

 2009-02-24 11:56:42 来源:WEB开发网   
核心提示: 这样在该StackPanel下的所有控件样式均应用了ExpressionLight主题,另外我们也可以在CS文件中对指定的控件设置相应的主题,使用Silverlight Toolkit中的主题(Theme)(2),比如本DEMO中所写的代码:publicPage(){Initialize

这样在该StackPanel下的所有控件样式均应用了ExpressionLight主题。另外我们也可以在CS

文件中对指定的控件设置相应的主题,比如本DEMO中所写的代码:

public Page()
{
    InitializeComponent();
    this.ThemeList.SelectionChanged += new SelectionChangedEventHandler(ThemeList_SelectionChanged);
    this.Loaded += new RoutedEventHandler(Page_Loaded);
}

void Page_Loaded(object sender, RoutedEventArgs e)
{
    ThemeList.Items.Add(new ComboBoxItem() { Name = "ExpressionDark", Content = "ExpressionDark", DataContext = "themes/ExpressionDark.xaml", IsEnabled = true });
    ThemeList.Items.Add(new ComboBoxItem() { Name = "ExpressionLight", Content = "ExpressionLight", DataContext = "themes/ExpressionLight.xaml" });
    ThemeList.Items.Add(new ComboBoxItem() { Name = "RainierOrange", Content = "RainierOrange", DataContext = "themes/RainierOrange.xaml" });
    ThemeList.Items.Add(new ComboBoxItem() { Name = "RainierPurple", Content = "RainierPurple", DataContext = "themes/RainierPurple.xaml" });
    ThemeList.Items.Add(new ComboBoxItem() { Name = "RainierRadialBlue", Content = "RainierRadialBlue", DataContext = "themes/RainierRadialBlue.xaml" });
    ThemeList.Items.Add(new ComboBoxItem() { Name = "ShinyBlue", Content = "ShinyBlue", DataContext = "themes/ShinyBlue.xaml" });
    ThemeList.Items.Add(new ComboBoxItem() { Name = "ShinyDarkGreen", Content = "ShinyDarkGreen", DataContext = "themes/ShinyDarkGreen.xaml" });
    ThemeList.Items.Add(new ComboBoxItem() { Name = "ShinyDarkPurple", Content = "ShinyDarkPurple", DataContext = "themes/ShinyDarkPurple.xaml" });
    ThemeList.Items.Add(new ComboBoxItem() { Name = "ShinyDarkTeal", Content = "ShinyDarkTeal", DataContext = "themes/ShinyDarkTeal.xaml" });
    ThemeList.Items.Add(new ComboBoxItem() { Name = "ShinyRed", Content = "ShinyRed", DataContext = "themes/ShinyRed.xaml" });

    SetTheme(ThemeList.Items[0] as ComboBoxItem);
}

private void ThemeList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    SetTheme(ThemeList.SelectedItem as ComboBoxItem);
}

//设置相应的theme
void SetTheme(ComboBoxItem comboBoxItem)
{
    if (comboBoxItem != null)
    {
        ControlPage control = new ControlPage();
        Test.Children.Clear();
        Test.Children.Add(control);

        Uri uri = new Uri(comboBoxItem.DataContext.ToString(), UriKind.Relative);
        ImplicitStyleManager.SetResourceDictionaryUri(control, uri);
        ImplicitStyleManager.SetApplyMode(control, ImplicitStylesApplyMode.Auto);
        ImplicitStyleManager.Apply(control);
    }
}

上一页  1 2 3 4  下一页

Tags:使用 Silverlight Toolkit

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接