您的位置:首页 > 移动开发

Windows Store apps开发[45]修改ProgressBar的颜色

2012-11-04 14:24 411 查看
当前位置: 银光首页 > Windows
8 > Windows 8学习教程 >



时间:2012-10-21 18:49来源:CSDN 作者:beyondvincent 点击:129次

如果你想要修改ProgressBar的foreground 颜色,用下面的方法是不行的: ProgressBarIsIndeterminate= True Foreground= Aquamarine / 要修改ProgressBar的颜色,需要override默认主题资源字典中的如下值: ResourceDictionary.ThemeDictionaries ResourceDictionaryx:Key= Default x: String x:Key= ProgressBarIndetermin

  

  如果你想要修改ProgressBar的foreground 颜色,用下面的方法是不行的:

<ProgressBar IsIndeterminate="True" Foreground="Aquamarine" />

  要修改ProgressBar的颜色,需要override默认主题资源字典中的如下值:

<ResourceDictionary.ThemeDictionaries>

<ResourceDictionary x:Key="Default">

<x:String x:Key="ProgressBarIndeterminateForegroundThemeBrush">Red</x:String>

</ResourceDictionary>

</ResourceDictionary.ThemeDictionaries>

  可以将这个override添加到App.xaml中,或者创建一个新的资源字典,并合并到App.xaml中:

  A、直接添加到App.xaml中,如下代码:

<Application.Resources>

<ResourceDictionary>

<ResourceDictionary.ThemeDictionaries>

<ResourceDictionary x:Key="Default">

<x:String x:Key="ProgressBarIndeterminateForegroundThemeBrush">Red</x:String>

</ResourceDictionary>

</ResourceDictionary.ThemeDictionaries>

<ResourceDictionary.MergedDictionaries>

<!--

Styles that define common aspects of the platform look and feel

Required by Visual Studio project and item templates

-->

<ResourceDictionary Source="Common/StandardStyles.xaml"/>

</ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

</Application.Resources>

  B、创建了一个CustomStyles.xaml,并将该文件合并到App.xaml中:

<Application

x:Class="Sample.App"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">



<Application.Resources>

<ResourceDictionary>

<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source="Common/StandardStyles.xaml" />

<ResourceDictionary Source="Common/CustomStyles.xaml" />

</ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

</Application.Resources>

</Application>

  CustomStyles.xaml:

<ResourceDictionary

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<!-- Global Overrides -->

<ResourceDictionary.ThemeDictionaries>

<ResourceDictionary x:Key="Default">

<x:String x:Key="ProgressBarIndeterminateForegroundThemeBrush">Red</x:String>

</ResourceDictionary>

</ResourceDictionary.ThemeDictionaries>

</ResourceDictionary>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: