Making the MaintainExtentBehavior works

2119
1
01-18-2013 12:47 AM
Labels (1)
StéphaneVouillamoz
New Contributor
Hello,

I have the pretty simple map application below. In the code behind I programmatically add the layers and zoom to a particular extent at startup. The map displays as expected. See images in attachment.
But when I resize the window, the map is not adjusted accordingly.
I tried to remove the width and height properties of the map but it then displays a very tiny image...

I would appreciate any hints toward making this work!

Thanks

Vouillas


<Window x:Class="VaccinationTrackingSystem.MapClient.MainWindow"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        Title="Map" Height ="600" Width ="800" Closing="Window_Closing">
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition MaxWidth="200" MinWidth="200"/>
        </Grid.ColumnDefinitions>
        <esri:Map x:Name="_map" Grid.Column="0" UseAcceleratedDisplay="False" Width="600" Height="600" HorizontalAlignment="Left" VerticalAlignment="Top">
            <i:Interaction.Behaviors>
                <esri:MaintainExtentBehavior />
            </i:Interaction.Behaviors>
        </esri:Map>
        <esri:MapProgressBar x:Name="MyProgressBar" Grid.Column="0"
            Map="{Binding ElementName=_map}"
            HorizontalAlignment="Center" VerticalAlignment="Bottom"
            Width="150" Height="12"
            Margin="5"  />
        <esri:ScaleLine Grid.Column="0" Map="{Binding ElementName=_map}" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="Black"/>
        <esri:Navigation Grid.Column="0" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top"
                         Map="{Binding ElementName=_map}"  />

        <esri:Legend Grid.Column="1" Name="_legend" HorizontalAlignment="Right" VerticalAlignment="Top" ShowOnlyVisibleLayers="True"
               Width="200" Map="{Binding ElementName=_map}">
        </esri:Legend>
    </Grid>
</Window>
0 Kudos
1 Reply
by Anonymous User
Not applicable
Original User: dbroux

To get the Map to resize correctly you need to remove the Width, Height, HorizontalAlignment and VerticalAlignment properties., i.e:
<esri:Map x:Name="_map" Grid.Column="0" UseAcceleratedDisplay="False"/>
0 Kudos