Hello
I am using a DataGrid in a WPF app that has several (literally one for each day of the week) columns which differ only in their data index. A sample of the xaml is below.
How can I refactor this into something more DRY?
Cheers,
Berryl
SAMPLE XAML (two of seven columns):
<dg:DataGridTextColumn
Header="{Binding Source={StaticResource spy}, Path=DataContext[0].EventDate, Converter={StaticResource dateConv}}"
CellStyle="{StaticResource DataEntryCellStyle}" Width="60" CanUserResize="False"
Binding="{Binding Allocations[0].Amount, Converter={StaticResource amtConv}}"
/>
<dg:DataGridTextColumn
Header="{Binding Source={StaticResource spy}, Path=DataContext[1].EventDate, Converter={StaticResource dateConv}}"
CellStyle="{StaticResource DataEntryCellStyle}" Width="60" CanUserResize="False"
Binding="{Binding Allocations[1].Amount, Converter={StaticResource amtConv}}"
/>
== EDITED ADD'L INFO @ JALFP ===
Compiler complains that the target type is not a framework element when building
<Style x:Key="dayOfWeekColumn" TargetType="dg:DataGridTextColumn" >
<Setter Property="CanUserResize" Value="False"/>
<Setter Property="CanUserSort" Value="False"/>
<Setter Property="Width" Value="60" />
<Setter Property="CellStyle" Value="{StaticResource dataEntryGridCellStyle}" />
</Style>
I don't see anything that looks like a ColumnStyle either. What property would I set this style to in the xaml for the DataGridTextColumn?