2014-09-27 56 views
0

嗨我只是想编辑滑块控件的默认样式,但是当我试图将它添加到我的应用程序的App.Xaml,它显示在ThemeResource KeyWord下的错误,这里是一部分的模板编辑风格在Windows手机

<Style x:Key="SomeStyle" TargetType="Slider"> 
     <Setter Property="Background" Value="{ThemeResource SliderTrackBackgroundThemeBrush}" /> 
     // Here ThemeResource is indicating error. 

我该如何解决这个问题?任何帮助表示赞赏:)

+0

这是一个Windows Phone 7,8或8.1应用程序? – 2014-09-27 22:28:44

+0

这是我现在正在运行的WP8。 – loop 2014-09-27 22:32:19

+0

ThemeResources可在WP 8.1 – 2014-09-27 22:35:02

回答

1

您需要在Windows Phone 8上使用StaticResource而不是ThemeResource。SliderTrackBackgroundThemeBrush来自Windows Runtime Slider控件,而不是Windows Phone Silverlight Slider控件。

如果您在设计器中选择滑块,则可以右键单击并选择编辑模板。编辑复制...上下文菜单以创建默认模板的副本。您可以根据需要编辑模板。

在默认样式启动如下。看看它如何定义Background属性的setter:

<Style x:Key="SliderStyle1" TargetType="Slider"> 
    <Setter Property="BorderThickness" Value="0"/> 
    <Setter Property="BorderBrush" Value="Transparent"/> 
    <Setter Property="Maximum" Value="10"/> 
    <Setter Property="Minimum" Value="0"/> 
    <Setter Property="Value" Value="0"/> 
    <Setter Property="Background" Value="{StaticResource PhoneChromeBrush}"/> 
    <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
+0

谢谢,这是值得了解的。 – loop 2014-10-01 08:49:26