Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Can i use child window control to show map legend or overview? I tried to use the child window control to show map legend but i couldn't make it work. Is there any way to use the child window control in ArcGIS Silverlight projects?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The child window control works like a modal dialog, or popup for your Silverlight application. When the child window appears, it sits on top of the parent window and stops you from doing anything to the parent window until you accept or close the child window.

The child window is useful to show display disclaimer information about the map, collect form data, or anything that you would use to interrupt the use of the map. Legend and overview could be done with this, but it's not recommended. They would be better suited to be placed directly on the map.

But if you're still interested, here's how to implement the legend using the child window.

XAML:

<controls:ChildWindow x:Class="myProject.PopupLegend"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
       xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
       xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
       Width="400" Height="300"
       Title="PopupLegend">
        <Grid x:Name="LayoutRoot" Margin="2">
            <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <esri:Legend x:Name="MyPopupLegend" Grid.Row="0" />
        <Button x:Name="CancelButton" Content="Cancel" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button x:Name="OKButton" Content="OK" Width="75" Height="23" HorizontalAlignment="Right"  Margin="0,12,79,0" Grid.Row="1" />
    </Grid>
</controls:ChildWindow>

Code Behind (VB.NET)

Partial Public Class PopupLegend
    Inherits ChildWindow

    Public Sub New(ByVal map As ESRI.ArcGIS.Client.Map)
        InitializeComponent()
        Me.MyPopupLegend.Map = map
    End Sub

    Private Sub OKButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles OKButton.Click
        Me.DialogResult = True
    End Sub

    Private Sub CancelButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles CancelButton.Click
        Me.DialogResult = False
    End Sub

End Class

And to call it up:

Dim popup = New PopupLegend(MyMap)
popup.Show()
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.