继WPF 4中的默认ProgressBar
模板应用了灰白色突出显示的问题导致它变暗前景色之后,我决定提取模板并手动将值编辑为白色。WPF忽略ProgressBar样式
完成此操作后,我将该模板作为App.xaml中的一种样式供全局使用,Visual Studio设计师立即开始使用它。
然而,当我跑我的应用程序,默认的风格仍然被应用:
Top - Application, Bottom - Designer http://www.nidonocu.com/temp_images/progress_problem.png
然后我尝试设置样式特别是使用一个密钥,那么即使有它作为一个内嵌式的最后作为没有特定进度条的包装样式的内联模板,并且仍然被忽略。
怎么回事?
电流为ProgressBar
代码:
<ProgressBar Grid.Column="1"
Grid.Row="2"
Height="15"
Width="355"
Margin="0,0,0,7"
IsIndeterminate="{Binding ProgressState, FallbackValue=False}"
Visibility="{Binding ProgressVisibility, FallbackValue=Collapsed}"
Value="{Binding ProgressValue, Mode=OneWay, FallbackValue=100}"
Foreground="{Binding ProgressColor,FallbackValue=Red}">
<ProgressBar.Template>
<ControlTemplate>
<Grid Name="TemplateRoot"
SnapsToDevicePixels="True">
<Rectangle RadiusX="2"
RadiusY="2"
Fill="{TemplateBinding Panel.Background}" />
...
'“{TemplateBinding Panel.Background}”'你确定你是绑定到面板的背景吗? – Amsakanna 2010-06-14 12:51:59
这是原始模板的一部分并且正确工作(在VS设计器中)。问题是整个模板在运行时没有显示出来。 – Nidonocu 2010-06-14 13:00:21