0

我需要让用户能够通过更改用户单击时的外观来个性化 Silverlight 应用程序。

我是 Silverlight 的新手,目前正在学习一些教程等。在以前的角色中熟悉 html/css,我在这里对现有 Silverlight 应用程序的一般样式做了一些工作。我现在的任务是添加此个性化设置,并希望对我应该如何处理它提出一些想法,非常感谢。

4

1 回答 1

0

您可以通过在资源字典中定义您的样式来实现这一点例如您想要按钮的 2 种外观让我们说主题 1 和主题 2 因此创建 2 个资源字典,以便每个资源字典包含不同样式的按钮。然后将您的按钮样式绑定为

<Button Style = {DynamicResource ButtonStyle} Height =23 Width = 70/>

其中 ButtonStyle 是资源字典中定义的样式的键 现在在用户单击 theme1

System.Windows.Application.Current.Resources.MergedDictionaries.Clear();
System.Windows.Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("/ProjectName;component/theme1.xaml", UriKind.RelativeOrAbsolute) });

并在用户单击主题2

 System.Windows.Application.Current.Resources.MergedDictionaries.Clear();
 System.Windows.Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("/ProjectName;component/theme2.xaml", UriKind.RelativeOrAbsolute) });

希望这可以帮助..

于 2013-06-05T06:06:24.663 回答