I'm trying to apply a style to an image inside a DataTemplate, but it doesn't seem to work. It works fine if the style is applied to an image outside the RadGridView.
Here's the xaml for the RadGridView, and I'm refering to Style
On the same VIEW where the code above resides, there's a link to a resource dictionary where the style is defined:
The style is defined on a ResourceDictionary as follows:
Any help is greatly appreciated.
Here's the xaml for the RadGridView, and I'm refering to Style
="{StaticResource ico16}" in the code below:<telerik:RadGridView Grid.Column="1" Grid.Row="1" AutoGenerateColumns="False" DataContext="{Binding Grid}" ItemsSource="{Binding XPath=/Collection}" RowIndicatorVisibility="Collapsed" ShowGroupPanel="False" GridLinesVisibility="Horizontal" telerik:StyleManager.Theme="Windows7"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Width="*"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" VerticalAlignment="Top" > <Image Source="{Binding XPath=@Icon}" ToolTip="{Binding XPath=@Tooltip}" Style="{StaticResource ico16}" /> <TextBlock Text="{Binding XPath=@Key}" Foreground="Black" /> </StackPanel> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> </telerik:RadGridView>On the same VIEW where the code above resides, there's a link to a resource dictionary where the style is defined:
<UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/MyAssemblyNameHere;component/Resources/MyResourceDictionary.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources>The style is defined on a ResourceDictionary as follows:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ico16" TargetType="Image"> <Setter Property="Margin" Value="0 0 5 0" /> <Setter Property="Width" Value="16"/> <Setter Property="Height" Value="16"/> <Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality"/> <Setter Property="Stretch" Value="UniformToFill"/> <Setter Property="VerticalAlignment" Value="Top"/> <Setter Property="HorizontalAlignment" Value="Left"/> </Style> </ResourceDictionary>Any help is greatly appreciated.