I recall in Silverlight the ability to place an Attribute on a given property in the Model for an alternate display name when auto generating columns on a data grid. Is this possible in WPF? I don't want to use the event handler to change the names.
A:
Zamboni
2010-10-11 22:50:35
That is via handling the event, I don't want to do that and I recall in SL the ability to place an Attribute for a property in the Model to define the alternate text
Aaron
2010-10-12 15:05:22
This is how I did it, but that said, please post your solution so I can use it too if/when you find one.
Zamboni
2010-10-12 17:03:52
Zamboni, found a solution, check below...
Aaron
2010-10-12 20:30:11
A:
Found it...here is what I was referencing DisplayAttribute, however that does not appear valid in WPF, only SL. For WPF it can be done like this...keeping everything in XAML...
<dg:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding DatabaseConnections, Mode=Default}">
<dg:DataGrid.Columns>
<dg:DataGridTextColumn Header="Display" Binding="{Binding DisplayName}"></dg:DataGridTextColumn>
</dg:DataGrid.Columns>
</dg:DataGrid>
...this allows you to change the DisplayName
property to get displayed as "Display" in the header of the DataGrid
.
Aaron
2010-10-12 20:29:51