QueryDetailsDataGrid.ItemsSource = args.FeatureSet.Features;
List<Graphic> lstGraphics = new List<Graphic>(); foreach (Graphic g in args.FeatureSet.Features) { if (g.Attributes.ContainsKey("GEOSCANREC")) { g.Attributes["GEOSCANREC"] = "<a href=\"http://geopub.nrcan.gc.ca/html/view_e.php?id=" + g.Attributes["GEOSCANREC"] + "\">GO</a>"; } lstGraphics.Add(g); } QueryDetailsDataGrid.ItemsSource = lstGraphics;
<slData:DataGridTemplateColumn> <slData:DataGridTemplateColumn.CellTemplate> <DataTemplate> <HyperlinkButton NavigateUri="{Binding Attributes[GEOSCANREC], StringFormat='http://geopub.nrcan.gc.ca/html/view_e.php?id=\{0\}'}" Content="Click here" TargetName="_blank" /> </DataTemplate> </slData:DataGridTemplateColumn.CellTemplate> </slData:DataGridTemplateColumn>
I don't know your context but it looks like you are trying to display HTML inside Silverlight. That's not that easy.
If you stay inside Silverlight, you should use an 'HyperlinkButton' and set the NavigateUri property.
Inside a datagrid, you can define a column like this:
<slData:DataGridTemplateColumn> <slData:DataGridTemplateColumn.CellTemplate> <DataTemplate> <HyperlinkButton NavigateUri="{Binding Attributes[GEOSCANREC], StringFormat='http://geopub.nrcan.gc.ca/html/view_e.php?id=\{0\}'}" Content="Click here" TargetName="_blank" /> </DataTemplate> </slData:DataGridTemplateColumn.CellTemplate> </slData:DataGridTemplateColumn>
string attributeName = "GEOSCANREC"; DataTemplate cellTemplate = (DataTemplate)System.Windows.Markup.XamlReader.Load( @"<DataTemplate xmlns=""http://schemas.microsoft.com/client/2007""> <HyperlinkButton NavigateUri=""{Binding Attributes[" + attributeName + @"], StringFormat='http://geopub.nrcan.gc.ca/html/view_e.php?id=\{0\}'}"" Content=""Click here"" TargetName=""_blank"" /> </DataTemplate>"); queryDetailsDataGrid.Columns.Add(new DataGridTemplateColumn() { Width = new DataGridLength(100), Header = "Hyperlink", CellTemplate = cellTemplate });
<slData:DataGridTemplateColumn Header="Email"> <slData:DataGridTemplateColumn.CellTemplate> <DataTemplate> <HyperlinkButton NavigateUri="{Binding Attributes[Email], StringFormat='mailto:\{0\}'}" Content="Email" TargetName="_blank" Foreground="Blue" FontWeight="Normal"/> </DataTemplate> </slData:DataGridTemplateColumn.CellTemplate> </slData:DataGridTemplateColumn>