Select to view content in your preferred language

How to collapse a textblock in an infowindow

505
0
05-06-2013 12:50 PM
DonFreeman
Emerging Contributor
If I create a maptip like this
<esri:FeatureLayer.MapTip >
         <Border Style="{StaticResource MapTip_Border}" esri:FeatureLayer.MapTipHideDelay="00:00:02.5">
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [NAME]}" Foreground="Black"  FontWeight="Bold"/>
          <TextBlock Text="{Binding [ADDRESS]}" Foreground="Black" />
          <TextBlock Text="__________________________________________" Foreground="Black" />
          <TextBlock Text="Pollutants that are monitored at this site" Foreground="Black" />
          <TextBlock Text="{Binding [PM1]}" Foreground="Black" />
          <TextBlock Text="{Binding [PM2]}" Foreground="Black" />
          <TextBlock Text="{Binding [CO]}" Foreground="Black" />
          <TextBlock Text="{Binding [O3]}" Foreground="Black" />
          <TextBlock Text="{Binding [SO2]}" Foreground="Black" />
          <TextBlock Text="{Binding [NOX]}" Foreground="Black" />
          <HyperlinkButton x:Name="myHyperLink" NavigateUri="{Binding [WebLink]}" TargetName="_blank" Content="Click here for more info." Foreground="DarkSlateBlue"/>
         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>

and the textblock value is empty, the textblock automatically collapses and take up no space in the maptip.
However, if I create an infowindow like this
<DataTemplate x:Key="DataWindowTemplate">
    <StackPanel Margin="2">
     <TextBlock Text="{Binding [NAME]}" Foreground="Black"  FontWeight="Bold"/>
     <TextBlock Text="{Binding [ADDRESS]}" Foreground="Black" />
     <TextBlock Text="__________________________________________" Foreground="Black" />
     <TextBlock Text="Pollutants that are monitored at this site" Foreground="Black" />
     <TextBlock Text="{Binding [PM1]}" Foreground="Black" />
     <TextBlock Text="{Binding [PM2]}" Foreground="Black" />
     <TextBlock Text="{Binding [CO]}" Foreground="Black" />
     <TextBlock Text="{Binding [O3]}" Foreground="Black" />
     <TextBlock Text="{Binding [SO2]}" Foreground="Black" />
     <TextBlock Text="{Binding [NOX]}" Foreground="Black" />
     <HyperlinkButton x:Name="myHyperLink" NavigateUri="{Binding [WebLink]}" TargetName="_blank" Content="Click here for more info." Foreground="DarkSlateBlue"/>
     <Image Source="/SLAirQualityBusinessApplication;component/Assets/Images/CloseX.png" HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="16" Width="15"/>
    </StackPanel>
   </DataTemplate>
 <esri:InfoWindow x:Name="MyInfoWindow"
                                 Padding="2"
                                 CornerRadius="5" 
                                 Background="WhiteSmoke"
                                 Map="{Binding ElementName=MyMap}" 
                                 ContentTemplate="{StaticResource DataWindowTemplate}"
                                 MouseLeftButtonUp="MyInfoWindow_MouseLeftButtonUp" />
an empty textblock still takes a row in the result. Is there a way to make the infowindow behave like the maptip so there are no empty rows in the result?

On further study I find that the first time the infowindow opens it DOES collapse the empty textblocks. It continues this as long as the point selected remains the same. However, when choosing a diffrent point (with different data) it then reserves the empty row space for the empty textblock. It continues to do this even after returning to the original point and data.

Thanks
0 Kudos
0 Replies