I have a simple Identify Layer tool, that should be displaying information in a popupviewer, however only the Title is being displayed in the PopupViewer Control.
Simplified example is below after following the Configure Clusters sample.
I have tried creating a PopupDefinition in numerous ways but the only thing that displays in the popupviewer is the Title. The rest remains blank. I have to be missing something.
Xaml
<esri:PopupViewer x:Name="popupViewer" Margin="5" Width="375" MaxHeight="400"/>
Xaml.cs
private async void PolkMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
{
//Hardcoded the Specific Layer
FeatureLayer _layer = (FeatureLayer)_mapView.Map.OperationalLayers[27] ?? new FeatureLayer();
var results = await _mapView.IdentifyLayerAsync(_layer, e.Position, 3, true);
//Resulting Pop is NOT Null and HAS a PopupDefinition with Fields
var p = results.Popups.First();
if (p != null)
{
popupViewer.Popup = p;
popupViewer.Visibility = System.Windows.Visibility.Visible;
Console.WriteLine("Title " + p.Title.ToString() + " Field count: " + p.PopupDefinition.Fields.Count());
}
}
PopupDefinition (Feature Layer is loaded from a .geodatabase file; Renderer and Label Definitions are created along with the PopupDefinition - only the popup is having issues)
parcelPolyLayer.IsPopupEnabled = true;
PopupDefinition newP = new PopupDefinition() { Title = "My Custom Title"};
PopupField newF = new PopupField() { Label = "Strap", FieldName = "JOIN_STRAP", IsEditable = true, IsVisible = true, StringFieldOption = PopupStringFieldOption.SingleLine };
newP.Fields.Add(newF);
parcelPolyLayer.PopupDefinition = newP;
Is the JOIN_STRAP field name correct? Did you make sure the feature you got is fully loaded and has that attribute in it?
You can ignore the binding errors for now
The field name is correct, and I did try a few other fields, including surrounding with [brackets]. I added screenshots while stepping through in case you can see anything.
Fields in the Table and Attributes on the Layer. Then the FieldPopupElement which has the single field item - newF.
Also included how the Table and FeatureLayer are loaded and the exact code used to create the definition.
Thank you for the help on this.
Geodatabase? parcelsDb = LoadGeodatabase(localPath);
parcelsTable = parcelsDb.GetGeodatabaseFeatureTable("SVA_MGIS");
var parcelPolyLayer = new FeatureLayer(parcelsTable);
parcelPolyLayer.LoadAsync().Wait();
parcelPolyLayer.IsPopupEnabled = true;
PopupDefinition newP = new PopupDefinition() { Title = "My Custom Title" };
PopupField newF = new PopupField() { Label = "Strap", FieldName = "JOIN_STRAP", IsEditable = true, IsVisible = true, StringFieldOption = PopupStringFieldOption.SingleLine };
newP.Elements.Add(new TextPopupElement("This is just some <b>generic text</b> you can add"));
newP.Elements.Add(new FieldsPopupElement(new[] { newF }) { Title = "Attributes" });
parcelPolyLayer.PopupDefinition = newP;
//Layer is then added to Map.OperationalLayers
> Also included how the Table and FeatureLayer are loaded
I was referring to the feature itself. Try adding (feature as ILoadable)?.LoadAsync(); before assigning it to the popup. Also assert that the feature itself does have that attribute populated.
Lastly set a breakpoint on the Popup that is returned from identify, call "await Popup.EvaluateExpressionsAsync()" and inspect "EvaluatedElements" and verify the fields are present
Added the LoadAsync, doesn't appear to make a difference, and EvaluatedElements to the GeoTapped Event.
I can see the 2 evaluated elements, text and field, both have the properties set as expected.
I can even see the correct value when looking at the FormattedValue...But still only the Titles and text field are displaying in the popup.
//Added LoadAsync but nothing changes with/without
await _layer.LoadAsync();
var results = await PolkMapView.IdentifyLayerAsync(_layer, e.Position, 3, true);
//The FormattedValue is Correct when looking at the EvaluatedElement
var p = results.Popups.First();
await p.EvaluateExpressionsAsync();
var evalElements = p.EvaluatedElements;
popupViewer.Popup = p;
Hmm that all looks good. I haven't been able to reproduce that behavior. Is there any chance you could share a small sample that reproduces the issue using some public data?
I am looking into getting a public set to provide here.
If it helps, this project is for a conversion from old ArcReader map that was using .gdb files to a map package using .geodatabase file as the source.
Our use of the popup is limited to one feature, so we might simply make a custom display and move on for now.