Using Popups

668
2
03-16-2018 08:08 AM
ClarkLangridge
Occasional Contributor II

Can someone please explain to me, in idiot-level detail, how you are supposed to use the Popup and PopupManager classes?

0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor

Popups are generally defined when creating your map, and defines how a feature should be displayed. Usually these are authored when publishing your webmap.

You can think of the PopupManager as the ViewModel for the popup+feature instance. It helps you generate the view of the popup, formatting values for view etc. For instance a simple way to render the popup fields can be done like this:

<ItemsControl ItemsSource="{Binding DisplayedFields}">
     <ItemsControl.ItemTemplate>
          <DataTemplate>
               <StackPanel>
                    <TextBlock Text="{Binding Field.Label}" FontWeight="Bold"\ />
                    <TextBox IsEnabled="false" Text="{Binding FormattedValue, Mode=OneWay}" BorderThickness="0" />
               </StackPanel>
          </DataTemplate>
     </ItemsControl.ItemTemplate>
</ItemsControl>‍‍‍‍‍‍‍‍‍‍

If you want to edit a feature, you could bind to the editable fields:

<ItemsControl ItemsSource="{Binding EditableDisplayFields}">
     <ItemsControl.ItemTemplate>
          <DataTemplate>
               <StackPanel>
                    <TextBlock Text="{Binding Field.Label}" FontWeight="Bold" />
                    <TextBox Text="{Binding Value, Mode=TwoWay}" BorderBrush="Red">
                         <TextBox.Style>
                              <Style TargetType="TextBox">
                                   <Style.Triggers>
                                        <DataTrigger Binding="{Binding ValidationError}" Value="{x:Null}">
                                             <Setter Property="BorderBrush" Value="Black" />
                                        </DataTrigger>
                                   </Style.Triggers>
                              </Style>
                         </TextBox.Style>
                    </TextBox>
               </StackPanel>
          </DataTemplate>
     </ItemsControl.ItemTemplate>
</ItemsControl>
0 Kudos
artifact
New Contributor III

But how do we use the PopupManager to access PopupMedia and PopupExpressions?

0 Kudos