【发布时间】:2013-03-27 19:15:28
【问题描述】:
我想访问嵌套在样式控件模板中的属性。我知道您可以在代码隐藏中执行此操作:
GradientStop stop = (GradientStop)progressBar1.Template.FindName("gradStop", progressBar1);
stop.Color = Colors.Black;
是否可以这样做,但在 XAML 中?例如:
<ProgressBar Style="{StaticResource CustomProgressBar}" [???].Color="FF000000"/>
【问题讨论】:
-
据我所知你应该使用动态资源。
-
DynamicResource 可能是答案,是的,如果 ControlTemplate 构建正确。但是,如果您使用的是自定义模板,为什么还要尝试这样做?
标签: wpf xaml styles controltemplate