I have gis data in an sql-server database I need to bind to a datagrid. I can use an ria service and bind the data directly to the datagrid but ideally, I would like to loop through the fields in these entities and create hyperlinks for certain fields prior to adding the data to the datagrid. Does anyone have any thoughts on how to approach this problem ?Thanks,
One of the ways to do...1) For your datagrid, set the AutoGenerateColumns="false"As an example<sdk: DataGrid x:Name="RIADataGrid" AutoGenerateColumns="false" ...>2) Populate your columnsAs an example<sdk: DataGrid x:Name="RIADataGrid" AutoGenerateColumns="false" ...><sdk: DataGrid.Columns><sdk: DataGridTextColumn x:Name="FirstField" Binding="{Binding FirstField}" Header=" First Field"/><sdk: DataGridTextColumn x:Name="SecondField" Binding="{Binding SecondField}" Header=" Second Field"/><sdk: DataGridTextColumn x:Name="ThirdField" Binding="{Binding ThirdField}" Header=" Third Field"/>...</sdk: DataGrid.Columns></sdk: DataGrid>3) Depending on your field type, you can use one of the followinga) DataGridTextColumnb) DataGridCheckBoxColumnc) DataGridTemplateColumn4) Thus, if you want to have a hyperlink, you may want to use "DataGridTemplateColumn"As an example<sdk: DataGrid x:Name="RIADataGrid" AutoGenerateColumns="false" ...><sdk: DataGrid.Columns><sdk: DataGridTextColumn x:Name="FirstField" Binding="{Binding FirstField}" Header=" First Field"/><sdk: DataGridTextColumn x:Name="SecondField" Binding="{Binding SecondField}" Header=" Second Field"/><sdk: DataGridTextColumn x:Name="ThirdField" Binding="{Binding ThirdField}" Header=" Third Field"/><sdk: DataGridTemplateColumn x:Name="FourthField" Header=" Fourth Field"><sdk: DataGridTemplateColumn.CellTemplate><DataTemplate>//add a Hyperlink Control</DataTemplate></sdk: DataGridTemplateColumn.CellTemplate></sdk: DataGridTemplateColumn>...</sdk: DataGrid.Columns></sdk: DataGrid>5) Check the following link as wellhttp://msdn.microsoft.com/en-us/library/system.windows.controls.datagridtemplatecolumn(v=vs.95).aspx
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.