silverlight中动态切换主题样式

本文介绍如何在WPF应用程序中实现动态样式和主题切换功能。通过创建可复用的控件,并利用ComboBox选择不同的预设主题,实现了界面样式的动态改变。文章详细展示了从创建控件到主题切换的具体步骤。

所先需要引用System.Windows.Controls.Theming命名空间

然后,微软的提供了一些主题,可供使用,根据自己的需要来引用这些类

Microsoft.Windows.Controls.Theming.BubbleCream

Microsoft.Windows.Controls.Theming.BureauBlack

Microsoft.Windows.Controls.Theming.BureauBlue

Microsoft.Windows.Controls.Theming.ExpressionDark

Microsoft.Windows.Controls.Theming.ExpressionLight

Microsoft.Windows.Controls.Theming.RainierOrange

Microsoft.Windows.Controls.Theming.RainierPurple

Microsoft.Windows.Controls.Theming.ShinyBlue

Microsoft.Windows.Controls.Theming.ShinyRed

Microsoft.Windows.Controls.Theming.TwilightBlue

Microsoft.Windows.Controls.Theming.WhistlerBlue

然后分几部

1.添加一个名为Controls.xaml的UserControl,代码清单如下

<UserControl x:Class=”DynamicStylingExample.Controls” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:d=”http://schemas.microsoft.com/expression/blend/2008” xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:data=”clr- namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data” xmlns:controls=”clr- namespace:System.Windows.Controls;assembly=System.Windows.Controls”> <StackPanel x:Name=”ControlsRoot”> <StackPanel Orientation=”Horizontal” Margin=”0,10”> <Button Content=”Button Control” /> <TextBox Margin=”10,0,0,0” Width=”200” Text=”Styled TextBox” /> </StackPanel> <StackPanel Orientation=”Horizontal” Margin=”0,10”> <Slider Margin=”10,0,0,0” Maximum=”100” Minimum=”0” Value=”0” /> </StackPanel> <data:DataGrid x:Name=”CustomFoodsGrid” Margin=”0,10” /> <controls:Calendar Margin=”0,10” /> </StackPanel> </UserControl>

2.在MainPage.xaml文件中添加一个ComboBox,通过ComboBox来选择主题

<UserControl x:Class=”DynamicStylingExample.MainPage” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:dynamic=”clr-namespace:DynamicStylingExample”> <Grid x:Name=”LayoutRoot”> <StackPanel x:Name=”MainPanel”> <ComboBox x:Name=”ThemeList”> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text=”{Binding ThemeName}” /> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> <dynamic:Controls x:Name=”Controls” /> </StackPanel> </Grid> </UserControl>

3.写一个类用来填充ComboBox

public class ThemeSelector { public string ThemeName { get; set; } public ContentControl Theme { get; set; } }

4.写一个返回主题样式集合的方法在MainPage类的构造函数中调用

private void LoadThemeList() { List<ThemeSelector> themes = new List<ThemeSelector>(); themes.Add(new ThemeSelector { ThemeName = “BubbleCreme”, Theme = new BubbleCremeTheme() }); themes.Add(new ThemeSelector { ThemeName = “BureauBlack”, Theme = new BureauBlackTheme() }); themes.Add(new ThemeSelector { ThemeName = “BureauBlue”, Theme = new BureauBlueTheme() }); themes.Add(new ThemeSelector { ThemeName = “ExpressionDark”, Theme = new ExpressionDarkTheme() }); themes.Add(new ThemeSelector { ThemeName = “ExpressionLight” Theme = new ExpressionLightTheme() }); themes.Add(new ThemeSelector { ThemeName = “RainierOrange”, Theme = new RainierOrangeTheme() }); themes.Add(new ThemeSelector { ThemeName = “RainierPurple”, Theme = new RainierPurpleTheme() }); themes.Add(new ThemeSelector { ThemeName = “ShinyBlue”, Theme = new ShinyBlueTheme() }); themes.Add(new ThemeSelector { ThemeName = “ShinyRed”, Theme = new ShinyRedTheme() }); themes.Add(new ThemeSelector { ThemeName = “TwilightBlue”, Theme = new TwilightBlueTheme() }); themes.Add(new ThemeSelector { ThemeName = “WhistlerBlue”, Theme = new WhistlerBlueTheme() }); ThemeList.ItemsSource = themes; }

5.最后在ComboxBox的SelectionChanged事件中写更改主题的代码

private void ThemeList_SelectionChanged(object sender, SelectionChangedEventArgs e) { ContentControl theme = ((sender as ComboBox).SelectedItem as ThemeSelector).Theme; theme.Content = new Controls(); MainPanel.Children.RemoveAt(1); MainPanel.Children.Add(theme); }

内容概要:本文介绍了ENVI Deep Learning V1.0的操作教程,重点讲解了如何利用ENVI软件进行深度学习模型的训练与应用,以实现遥感图像中特定目标(如集装箱)的自动提取。教程涵盖了从数据准备、标签图像创建、模型初始化与训练,到执行分类及结果优化的完整流程,并介绍了精度评价与通过ENVI Modeler实现一键化建模的方法。系统基于TensorFlow框架,采用ENVINet5(U-Net变体)架构,支持通过点、线、面ROI或分类图生成标签数据,适用于多/高光谱影像的单一类别特征提取。; 适合人群:具备遥感图像处理基础,熟悉ENVI软件操作,从事地理信息、测绘、环境监测等相关领域的技术人员或研究人员,尤其是希望将深度学习技术应用于遥感目标识别的初学者与实践者。; 使用场景及目标:①在遥感影像中自动识别和提取特定地物目标(如车辆、建筑、道路、集装箱等);②掌握ENVI环境下深度学习模型的训练流程与关键参数设置(如Patch Size、Epochs、Class Weight等);③通过模型调优与结果反馈提升分类精度,实现高效自动化信息提取。; 阅读建议:建议结合实际遥感项目边学边练,重点关注标签数据制作、模型参数配置与结果后处理环节,充分利用ENVI Modeler进行自动化建模与参数优化,同时注意软硬件环境(特别是NVIDIA GPU)的配置要求以保障训练效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值