
<telerik:GridViewColumn Header="Notes" Width="50">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<telerik:RadButton Name="btnObj" Height="25" Width="25" Click="btnObj_Click">
<telerik:RadButton.Content>
<Image Name="imgNotes" Source="/Images/notes.png" Height="16" Width="16" />
</telerik:RadButton.Content>
</telerik:RadButton>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
7 Answers, 1 is accepted
The recommended approach to achieve this result is through defining CellTemplateSelector.
Have you checked our DataTemplateSelector demos?
The same is applicable to WPF as well.
Vanya Pavlova
the Telerik team

public class NotesButtonStyle : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
if (item is OBJECTIVEALL)
{
OBJECTIVEALL row = item as OBJECTIVEALL;
if (row.ManagerNotes == null && row.EmployeeNotes == null)
return NoNotes;
else
return HasNotes;
}
return null;
}
public Style HasNotes { get; set; }
public Style NoNotes { get; set; }
}
<UserControl.Resources>
<local:RatingMatcherStyle x:Key="ratingMatcherStyle">
<local:RatingMatcherStyle.RatingMisMatch>
<Style TargetType="telerik:GridViewCell">
<Setter Property="Foreground" Value="Red"></Setter>
</Style>
</local:RatingMatcherStyle.RatingMisMatch>
</local:RatingMatcherStyle>
<local:NotesButtonStyle x:Key="notesButtonStyle">
<local:NotesButtonStyle.HasNotes>
<Style TargetType="telerik:RadRibbonButton">
<Setter Property="SmallImage" Value="/Images/notes_empty.png"/>
</Style>
</local:NotesButtonStyle.HasNotes>
<local:NotesButtonStyle.NoNotes>
<Style TargetType="telerik:RadRibbonButton">
<Setter Property="SmallImage" Value="/Images/notes.png"/>
</Style>
</local:NotesButtonStyle.NoNotes>
</local:NotesButtonStyle>
</UserControl.Resources>
According your first reply you have RadButton not RadRibbonButton. Can you clarify?
Greetings,Vlad
the Telerik team


I believe in your case it would be better to create a converter instead of a StyleSelector. This would allow you to apply a Style on the RadRibbontButton based on your custom logic. I attached a sample project to demonstrate this approach. Please give ti a try and let me know if it works for you.
All the best,
Tina Stancheva
the Telerik team
