Select to view content in your preferred language

Displaying KeyValuePair on DataGrid, customization issue

1349
3
09-28-2010 07:43 AM
KevinSesock
Emerging Contributor
Hi all:

I've implemented something similar to the following example:

http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/start.htm#Identify

My reasons for doing so are that I have multiple layers that I'm querying against, and therefore, will have a variety of different data being returned.

My problem is that I have URLs in my data that need to be clickable. I'm at a loss as to how to make these links clickable in a DataGrid if it's only one row or cell, not an entire column (columns are easy, thankfully, after all). I've considered a multitude of different approaches, from "look for a third-party data-grid control", to "do something ugly with control templating", to "reserialize all the possible data I could be getting and display differently", to "just give up and have a good cry".

I'm leaning towards the final option. Since the data is coming to me in KeyValuePairs, I'm kind of up a creek on my code being simple and elegant, and I'm probably going to have to reserialize, at the least, unless anyone has any better ideas.

Any recommendations/comments/happy thoughts?
0 Kudos
3 Replies
AliMirzabeigi
Emerging Contributor
Kevin,

Please take a look at the following post:
http://forums.arcgis.com/threads/8797-Hyperlinking-possibilities?highlight=DataGrid

Hope this helps.
0 Kudos
KevinSesock
Emerging Contributor
Thanks for getting back to me. I've seen that. That just created more questions then it answered. For example, while testing in DataGrid_SelectionChanged method to see if the SelectedItem Key is "LINK" or "URL", I've discovered that (sender as DataGrid).SelectedItem returns a DataGridItem, not a KeyValuePair. Any thoughts on how to get the Key and then the value as well?
0 Kudos
AliMirzabeigi
Emerging Contributor
All KeyValue pairs are returned as a type created by FeatureDataGrid (something like ESRI.ArcGIS.Client.Toolkit.DataSource.TempType...). You would need to do the following to get the value of a property say, WEB_SITE in your SelectedItem, then check whether it contains a URL value:
object selectedItem = (sender as DataGrid).SelectedItem;
object stateName = selectedItem.GetType().GetProperty("WEB_SITE").GetValue(selectedItem, null);
0 Kudos