Let's say I created a default style for ScrollViewer based on the provided metro style like this:
Now, ScrollViewer is a control that it used in many of Telerik's control templates, e.g. in the ControlTemplate for ListBox. This is the source of your ListBoxStyle:
As you can see, the control template sets the attached Theme-property for the internal ScrollViewer. Briefly looking at the source code of this attached property, it seems like this is getting the control's (ScrollViewer in this case) Telerik style from the theme (Metro in this case) via GetThemeStyle() and - if not null - applies it. The problem is, that this circumvents the default style for ScrollViewer which I set above and always uses the built-in Telerik style. So I never see "MySuperSexyColor" for the ScrollViewer used in a ListBox. If you would omit the attached Theme property in the control template (e.g. you've done that in the RadWatermarkTextBox control template), MY default style for ScrollViewer would be used in the ListBox. At least that's what my tests say...
Am I correct? Is this the intended behaviour? If yes, how can I adjust the controls used in your control template without copying one billion lines of XAML (can't say how much I hate this) just to change one property? I even tried the evil way of modifiying the internal cached resources dictionary of the theme via reflection to add my dictionary so that the style lookup could find mine. But this is not possible in Silverlight due to access restrictions.
Thank you,
Stephan
<
Style
x:Key
=
"DefaultScrollViewer"
TargetType
=
"ScrollViewer"
Telerik:StyleManager.BasedOn
=
"Metro"
>
<
Setter
Property
=
"Background"
Value
=
"MySuperSexyColor"
/>
</
Style
>
<
Style
BasedOn
=
"{StaticResource DefaultScrollViewer}"
TargetType
=
"ScrollViewer"
/>
Now, ScrollViewer is a control that it used in many of Telerik's control templates, e.g. in the ControlTemplate for ListBox. This is the source of your ListBoxStyle:
<
Style
TargetType
=
"ListBox"
>
<
Setter
Property
=
"Padding"
Value
=
"1"
/>
...
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"ListBox"
>
<
Border
...>
<
ScrollViewer
x:Name
=
"ScrollViewer"
Margin
=
"0"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
Padding
=
"{TemplateBinding Padding}"
Background
=
"{TemplateBinding Background}"
>
<
ItemsPresenter
/>
</
ScrollViewer
>
</
Border
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
As you can see, the control template sets the attached Theme-property for the internal ScrollViewer. Briefly looking at the source code of this attached property, it seems like this is getting the control's (ScrollViewer in this case) Telerik style from the theme (Metro in this case) via GetThemeStyle() and - if not null - applies it. The problem is, that this circumvents the default style for ScrollViewer which I set above and always uses the built-in Telerik style. So I never see "MySuperSexyColor" for the ScrollViewer used in a ListBox. If you would omit the attached Theme property in the control template (e.g. you've done that in the RadWatermarkTextBox control template), MY default style for ScrollViewer would be used in the ListBox. At least that's what my tests say...
Am I correct? Is this the intended behaviour? If yes, how can I adjust the controls used in your control template without copying one billion lines of XAML (can't say how much I hate this) just to change one property? I even tried the evil way of modifiying the internal cached resources dictionary of the theme via reflection to add my dictionary so that the style lookup could find mine. But this is not possible in Silverlight due to access restrictions.
Thank you,
Stephan