I'm learning Silverlight (from scratch, I'm feeling a bit like a fish out of water here!). I'm having a look at the DataGrid class, and am playing around with custom templates for columns and column headers.
I want to display a grid that has a collection of columns that have a small image in the header (different image for each column), and display-only values in the cells, with each column's values being bound to a different property on the bound data.
I've done some reading and got it to work for one column with the xaml below. What I want to do is bundle this column up into some kind of reusable column, and then just add multiple instances of them in my grid, specifying values to define what image to use and what property to bind to.
Can someone help me out with some suggestions? I'm using Silverlight 3.0, btw.
here's the xaml I'm using for one column:
<data:DataGrid x:Name="_bidGrid" IsReadOnly="true" CanUserResizeColumns="False">
<data:DataGrid.Columns>
<data:DataGridTemplateColumn>
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding <bound property name goes here>}"/>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
<data:DataGridTemplateColumn.HeaderStyle>
<Style TargetType="dataprimitives:DataGridColumnHeader">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Image Source="<image url goes here>"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</data:DataGridTemplateColumn.HeaderStyle>
</data:DataGridTemplateColumn>
</data:DataGrid.Columns>
</data:DataGrid>