I suppose the problem I'm having is that the Identify widget/tool doesn't work on Feature Layers (they have to be just a dynamic service layer). So, I can't use FeatureService stuff if I want the layers to be identifiable. 😕
Use FeatureLayer::QueryAttachmentInfos to get list of attachments then bind it to ItemsControl contains hyperlink or whatever you want. featureLayer.QueryAttachmentInfos(selectedGraphic, (Action<IEnumerable<ESRI.ArcGIS.Client.FeatureService.AttachmentInfo>>)QueryAttachmentInfosCallback, (Action<Exception>)delegate(Exception ex) { MessageBox.Show(ex.ToString());}); private void QueryAttachmentInfosCallback(IEnumerable<ESRI.ArcGIS.Client.FeatureService.AttachmentInfo> attachments) { //Bind to Itemscontrol }
featureLayer.QueryAttachmentInfos(selectedGraphic, (Action<IEnumerable<ESRI.ArcGIS.Client.FeatureService.AttachmentInfo>>)QueryAttachmentInfosCallback, (Action<Exception>)delegate(Exception ex) { MessageBox.Show(ex.ToString());}); private void QueryAttachmentInfosCallback(IEnumerable<ESRI.ArcGIS.Client.FeatureService.AttachmentInfo> attachments) { //Bind to Itemscontrol }
Michelle,Did you ever find a solution to this? I'm looking to do something similar and have tried a few things with no luck.
I have a similar question except I want a link to show up in the identify results window using the Silverlight API. I figured out how to create a link for one attachment, but not for more than one attachment. I added a hyperlink button to the bottom of the identify results window and, in the c# code, pulled the first data value (object ID) from the selected feature in the comboBox and added that to the hyperlink uri. The attachment ID seemed to match the feature object ID. However, I am not sure how the attachment ID for the second one is generated so I am not able to create a link to it. I'm trying to access the feature attachment infos property, but I am not sure how to do so.Anyway, I hope that this gives you a little more info on how one might go about it. I'm not very familiar with the Viewer though.The attachment editor would be great except we don't want users to be able to add or delete attachments. Plus having a link in the identify results window would be more user friendly in our case.Thanks,Michelle
<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>
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); } }
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.