If you are displaying your results in a datagrid you can create a template column to properly format your hyperlink and build the first part of the url to your file. For example if in your attribute table you are only storing the attachment file name, file.pdf for example, you could create a template column in your xaml like this:
<UserControl.Resources>
<DataTemplate x:Key="DocSource">
<HyperlinkButton Foreground="White" NavigateUri="{Binding Attributes[source_doc], StringFormat=http://www.YourSite/SourceDocs/\{0\}}" Content="{Binding Attributes[source_doc]}" TargetName="_blank" />
</DataTemplate>
</UserControl.Resources>
Then in your QueryTask_ExecuteCompleted you would build the datagrid columns at runtime, rather than before hand. As you loop through the featureset to generate your columns you listen for the field source_doc. When you get to that column you generate the column using the DataTemplate above.ExecuteCompleted Code
if (featureSet != null && featureSet.Features.Count > 0)
{
int rec = 0;
foreach (var feature in featureSet.Features)
feature.Attributes["Rec"] = ++rec;
List<string> fields = new List<string>();
//generate the first column for record index
DataGridTextColumn dataGridTextColumnRec = new DataGridTextColumn();
Binding Recbinder = new Binding();
Recbinder.Path = new PropertyPath("Attributes[Rec]");
dataGridTextColumnRec.Header = "Rec";
Recbinder.Mode = BindingMode.OneWay;
dataGridTextColumnRec.Binding = Recbinder;
QueryDetailsDataGrid.Columns.Add(dataGridTextColumnRec);
//generate the other columns
foreach (var item in featureSet.FieldAliases)
{
if (item.Value == "source_doc") //Create a hyperlink column for document link
{
DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();
templateColumn.Header = "Source Doc";
templateColumn.CellTemplate = (DataTemplate)Resources["DocSource"];
QueryDetailsDataGrid.Columns.Add(templateColumn);
}
else
{
DataGridTextColumn dataGridTextColumn = new DataGridTextColumn();
Binding binder = new Binding();
fields.Add(item.Value); //FieldAliases is a Dictionary, the field name being the key and the field alias being the value.
binder.Path = new PropertyPath("Attributes[" + item.Key + "]");
dataGridTextColumn.Header = item.Value;
binder.Mode = BindingMode.TwoWay ;
dataGridTextColumn.Binding = binder;
QueryDetailsDataGrid.Columns.Add(dataGridTextColumn);
}
}
foreach (Graphic feature in featureSet.Features)
{
feature.Symbol = LayoutRoot.Resources["DefaultResultLineSymbol"] as LineSymbol;
selectionGraphicslayer.Graphics.Insert(0, feature);
}
}
You can create as many data templates as you need, then add another if statement to listen for them.Hope this helps!