请教大家一个关于silverlight中动态改变style中的值的问题
样式代码如下
<Style x:Key="Style2" TargetType="Primitives:DataGridColumnHeader"> <Setter Property="Foreground" Value="Red"/> <Setter Property="FontSize" Value="15"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Primitives:DataGridColumnHeader"> <Border Name="aaa" Background="Gold" Width="50"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style>
public static DependencyProperty BorderProperty = DependencyProperty.Register("Border", typeof(Border), typeof(MainPage), null); Style style = this.Resources["Style2"] as Style; SetterBaseCollection setterBaseCollection = style.Setters; Setter setter = setterBaseCollection[2] as Setter; ControlTemplate controlTemplate = setter.Value as ControlTemplate; object c = controlTemplate.GetValue(BorderProperty );