Select to view content in your preferred language

FeatureDataGrid Behaviour in WPF vs Silverlight

1091
3
09-28-2010 07:01 AM
stefanschlaefli
Regular Contributor
Hi
when I use an ESRI:FeatureDataGrid in a WPF control it looks different and behaves different than the same control with the same properties in a Silverlight application. Sorting of a FeatureDataGrid in WPF for example is not supported (there's no events for column headers, except drag and reordering events). But when I use the featureDataGridControl in Silverlight, sorting is out of the box available by clicking on the column headers. Has this something to do with the control template? How can I enable sorting on the FeatureDataGrid within a WPF Control?
Thanks
Stefan
0 Kudos
3 Replies
AliMirzabeigi
Emerging Contributor
Stefan,

FeatureDataGrid controls in ESRI API are extended verisons of Microsoft DataGrid controls in WPF and Silverlight platforms that are basically different controls. If some of your attributes are not sortable in WPF then you can do the following in your XAML code:
1) Set FeatureDataGrid's "AutoGenerateColumns" property to FALSE:
<esri:FeatureDataGrid AutoGenerateColumns="False" ................ >
</esri:FeatureDataGrid>

2) Define DataGrid columns collection in your FeatureDataGrid for the attributes you would like to shown and set their "CanUserSort" property to TRUE:
<DataGrid.Columns>
    <DataGridTextColumn Binding="{Binding STATE_NAME}" Header="State Name" CanUserSort="True" />
    <!-- More columns here (could be DataGridComboBoxColumn, DataGridComboBoxColumn, DataGridTemplateColumn, or a DataGridTemplateColumn -->
</DataGrid.Columns>
0 Kudos
stefanschlaefli
Regular Contributor
Hi Ali
Thank you very much for this hint, it works fine . Do you also know if I can format the values in the TextColumns (rounding of values etc.)?
Thank you
Stefan
0 Kudos
AliMirzabeigi
Emerging Contributor
You can use "StringFormat" in your Binding.
e.g.)
<!-- POPULATION is an integer field (shows 1,000,000 for 1000000) -->
<DataGridTextColumn Binding="{Binding POPULATION, StringFormat=0\,000}" Header="POPULATION" CanUserSort="True" />
<!-- STATS_DATE is a DateTime field -->
<DataGridTextColumn Binding="{Binding STATS_DATE, StringFormat='MM-DD-YYYY'}" Header="STATS_DATE" CanUserSort="True" />
0 Kudos