<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="ThemeStyles\TH_ScrollViewer.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
<Style x:Key="{x:Type ScrollViewer}" TargetType="{x:Type ScrollViewer}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ScrollViewer}"> <Grid removed="{TemplateBinding Background}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" KeyboardNavigation.DirectionalNavigation="Local" CanContentScroll="True" CanHorizontallyScroll="False" CanVerticallyScroll="False" Margin="2,1,2,1"/> <ScrollBar x:Name="PART_HorizontalScrollBar" Orientation="Horizontal" Grid.Row="1" Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Value="{TemplateBinding HorizontalOffset}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Template="{DynamicResource HorizontalScrollBar}"/> <ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" ViewportSize="{TemplateBinding ViewportHeight}" Value="{TemplateBinding VerticalOffset}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Template="{DynamicResource VerticalScrollBar}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
Quote:On the creation of every object in XAML, if a default style is present (i.e. style w/ a key of Type) that style should be applied. As you can imagine there are several performance optimizations to make that (implied) lookup a light weight as possible. One of them is that we don’t look inside Resource Dictionaries unless they are flagged as “containing default Styles”. There is a bug: if all your default styles are nested in merged dictionaries three levels deep (or deeper) the top dictionary does not get flagged so the search skips it. The work around is to put a default Style to something, anything, in the root Dictionary.
<application.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary> Source="ThemeStyles\TH_ScrollViewer.xaml" /> </resourcedictionary></resourcedictionary.mergeddictionaries> <!-- Dummy Style, anything you won't use goes --> <style targettype="{x:Type Rectangle}" /> </resourcedictionary> </application.resources>
TargetType
x:Key
<resourcedictionary source="/<namespace>;component/ThemeStyles/TH_ScrollViewer.xaml" />
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <resourcedictionary.mergeddictionaries> <resourcedictionary source="Windows8/Telerik.Windows.Controls.RibbonView.xaml" /> <resourcedictionary> <style x:key="MyThemeRadRibbonViewStyle" targettype="{x:Type telerik:RadRibbonView}" basedon="{StaticResource ResourceKey=RadRibbonViewStyle}" xmlns:x="#unknown" /> </resourcedictionary> </resourcedictionary.mergeddictionaries> </resourcedictionary>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)