gpt4 book ai didi

silverlight-4.0 - 使用 Silverlight 4 应用主题

转载 作者:行者123 更新时间:2023-12-04 07:05:59 24 4
gpt4 key购买 nike

所以我已经尝试了一段时间让主题在 Silverlight 4 中工作。

我添加了对 System.Windows.Controls.Theming.Toolkit 和 System.Windows.controls.Theming.ShinyRed 的引用

然后我去做了这样的事情:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input" xmlns:WebbyDraw="clr-namespace:WebbyDraw" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     x:Class="SilverlightApplication1.MainPage"
Width="960" Height="700" mc:Ignorable="d"
xmlns:shinyRed="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.ShinyRed" >
<shinyRed:ShinyRedTheme>
<Grid x:Name="LayoutRoot2">
....
</Grid>
</shinyRed:ShinyRedTheme>
</UserControl>

但我总是得到相同的旧主题...没有错误,但也没有任何反应。我还尝试了 Silverlight 4 工具包中的其他主题,还尝试将它应用于单个控件……没有……我做错了什么?我已经阅读了几个教程,但没有找到答案。

最佳答案

这就是我使用主题的方式,我还允许我的用户更改为他们喜欢的主题 -
您可以用任何其他样式资源文件替换 ShinyRed.xaml 以支持多个主题,也可以通过编程方式完成(删除一个资源字典并添加另一个)。

在你的用户控件xmal中

xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
<toolkit:Theme x:Name="ThemeContainer">
<Grid x:Name="LayoutRoot">
... all other controls in the page
</Grid>

复制 shinyred 主题所需的所有画笔和字体,并创建一个名为 ShinyRed.xaml 的样式文件(您可以简单地按照每个文件中的包含将其全部放在一个文件中)

因此,在您的 App.xaml 中引用这个新创建的 xaml 和它正在编译和运行!

<Application.Resources>
<ResourceDictionary>

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/ShinyRed.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

关于silverlight-4.0 - 使用 Silverlight 4 应用主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3628322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com