I’m using Telerik RadControls for Silverlight and I need to draw list of strings in a column. I have bound column’s cellStyle to a style and added an instance of my ListCellPresenter control within that style. My control receives its internal data with the dependency property DataList. How can I bind the actual data that needs to be drawn to GridView, so that it will be accessible in ListCellPresenter?
<Grid x:Name="LayoutRoot">
<telerik:RadGridView x:Name="gvMain" AutoGenerateColumns="True">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Width="200" CellStyle="{StaticResource listStyle}" Header="New Column">
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
Here’s the style:
<UserControl.Resources>
<Style TargetType="grid:GridViewCell" x:Key="listStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="grid:GridViewCell">
<local:ListCellPresenter DataList="{Binding DataList}"></local:ListCellPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
It should be straightforward — just use
DataMemberBindingto point to the property of your row object that contains the list you want to bind to. Ie:(Assuming here that the
ItemsSourceof theRadGridViewis something likeIEnumerable<MyModel>whereMyModelcontains your objectiveList<string> TheListProperty.)