c# – XAML WinRT – 自定义样式的工厂模式
发布时间:2020-12-15 07:40:50 所属栏目:百科 来源:网络整理
导读:我想为XAML实现一种工厂模式.我为WinRT创建了一个应用程序,我在其中定义了两个xaml样式文件.基本上,我想要实现的(如果可能的话)是在应用程序启动时加载两个xaml文件中的一个. 在解决方案资源管理器中我有这个: CustomStyles foder包含样式文件.所以,基于我
我想为XAML实现一种工厂模式.我为WinRT创建了一个应用程序,我在其中定义了两个xaml样式文件.基本上,我想要实现的(如果可能的话)是在应用程序启动时加载两个xaml文件中的一个.
在解决方案资源管理器中我有这个: CustomStyles foder包含样式文件.所以,基于我的App.xaml.cs文件中的枚举器 public enum Style { Style_1,Style_2 } 如果我选择Style_1,我想在运行时加载xaml文件Style_1.xaml else Style_2.xaml. Style_1.xaml <Style x:Key="Attribute_Label" TargetType="TextBlock"> <Setter Property="FontFamily" Value="Segoe UI" /> <Setter Property="Foreground" Value="#78CAB3" /> <Setter Property="FontSize" Value="15" /> <Setter Property="FontWeight" Value="Normal" /> </Style> Style_2.xaml <Style x:Key="Attribute_Label" TargetType="TextBlock"> <Setter Property="FontFamily" Value="Arial" /> <Setter Property="Foreground" Value="#606060" /> <Setter Property="FontSize" Value="30" /> <Setter Property="FontWeight" Value="Normal" /> </Style> 有办法实现我想做的事情吗?先感谢您. 解决方法
我们最终会做这样的事情:
>使用所有CustomStyles在App.xaml中定义ResourcesDictionary 我们还没有找到任何更好的解决方案,但似乎有效. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |