Select to view content in your preferred language

Creating Popup Definition

380
15
11-07-2024 08:41 AM
Labels (2)
HS_PolkGIS
Occasional Contributor

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;

 

 

 

 

 

 

 

 

0 Kudos
15 Replies
HamishDuff
Esri Contributor

Hi @HS_PolkGIS,

I've managed to reproduce the issue you're seeing. 

I'm going to check to see if there is another way to achieve this and get back to you. 

Thanks for your question. 

0 Kudos
HamishDuff
Esri Contributor

@HS_PolkGIS my problem was addressed by adding the line:

newP.Elements.Add(new FieldsPopupElement(new[] { newF }) { Title = "Attributes" });

 
Are you still having issues?

0 Kudos
HS_PolkGIS
Occasional Contributor

Yes, after adding that line the popup still only displays the Titles and static Text Field elements. The popup definition does have the correct evaluated field values which can be seen stepping through code.

0 Kudos
HamishDuff
Esri Contributor

I see in another response you've mentioned looking into providing a public set of data for us to try to reproduce your issue with. 

If you are able to do that it would be helpful as I'm unable to reproduce the issue here. 

0 Kudos
SomeGISGuy
Occasional Contributor

Could you try setting height instead of the maxheight? I wonder if it is rendering, but just not sizing itself right.

0 Kudos
HS_PolkGIS
Occasional Contributor

That would have been a nice easy fix but unfortunately, still the same except a bigger popup.

<esri:PopupViewer x:Name="popupViewer" Margin="5" Width="375" Height="250" MaxHeight="400" />

popup.png

 

 

0 Kudos
SomeGISGuy
Occasional Contributor

-

0 Kudos
dotMorten_esri
Esri Notable Contributor

Thanks for confirming. On second look I realize you're adding to Fields and not Elements.
Try this instead:

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" });

0 Kudos
HS_PolkGIS
Occasional Contributor

Making a little progress.

All of the "static" text is appearing in the Popup but I am getting binding errors. All the original code is the same but I used the suggested TextPopupElements and the FieldsPopupElement lines... Adding a AttachmentsPopupElement with displaytype of list did not resolve anything.

The first error happens on app loading and the 2nd happens when the popup is set in the geotapped event. The error seems to be expecting an AttachmentsPopupElement and not the FieldsPopupElement.

popupError.png

popup2.png

0 Kudos