Select to view content in your preferred language

Minimal Map Template Full Extent

3054
12
08-24-2011 04:08 PM
ChristineZeller
Occasional Contributor
I'm trying to change the Full Extent for the Minimal Template off the Interactive SDK.  I believe the xaml in the DarkStyle.xaml and/or BlueStyle.xaml is setting the properties of the button/icon (Height, ToolTip, etc) but I can't find the code to change the fullextent.

 <Button x:Name="ZoomFullExtent" Height="20" FontSize="8" Width="20" ToolTipService.ToolTip="Full Extent" Margin="2,0,2,5" Style="{StaticResource ClearButtonStyle}" Foreground="White" Padding="-5" Cursor="Hand" >
                                                            <Button.Content>

                                                                <Grid x:Name="ZoomFullExtentGrid" Height="20" Width="20" ToolTipService.ToolTip="Full Extent" Margin="-1,0,2,5" >
                                                                    <icons:WorldGlobe Scale="0.75" ExpandOnMouseOver="True" Cursor="Hand" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="-5" OceanFill="{StaticResource oceanBrush}" LandFill="{StaticResource landBrush}" />
                                                                </Grid>

                                                            </Button.Content>
                                                        </Button>



I think it is just taking the extent of all my services or the first service layer but I would like to do something like to set it to a single layer or something like this

 <i:Interaction.Triggers>
                                                    <i:EventTrigger EventName="Click">
                                                        <esri:ZoomToAction TargetName="Map">
                                                            <esri:ZoomToAction.Geometry>

                                                                <esri:Envelope XMin="-122.9" YMin="40.9" XMax="-117.9" YMax="30.1" />


                                                            </esri:ZoomToAction.Geometry>
                                                        </esri:ZoomToAction>
                                                    </i:EventTrigger>
                                                </i:Interaction.Triggers>



But this doesn't work or I don't know where to add it or where to find the code when the icon/button is click.  Can you help me?

Thanks
0 Kudos
12 Replies
DominiqueBroux
Esri Frequent Contributor

Thanks for the post but that code is not in the Navigation.cs file.


You are right, I got lost with the 2 controls : 'Navigator' defined in the project and 'Navigation' defined in the toolkit.

Navigator inherits from Navigation and the full extent code is defined in the Navigation.cs file of the toolkit.

If you want to change this behavior without changing the toolkit you can change the name of the button in DarkStyles.xaml and hook up your own handler to the click event in 'Navigator.cs'.

Sorry for the confusion.
0 Kudos
ChristineZeller
Occasional Contributor
Dominique,
Thanks again, I think I can do that I'm just having problems with the "HOOKING PART"
would I bind it somehow like:
Click="{Binding ElementName=Minimal.Navigator.ZoomFullExtent_Click}"

??
Thanks
0 Kudos
ChristineZeller
Occasional Contributor
Dominique and Jennifer,

Thanks for all your help...I finally got it.  Just in-case someone else is interested here's what I did. 

I changed the button name, in the DarkStlye.xaml to ZoomFullExtent1

Then in the Navigation.cs file I added to following:

[TemplatePart(Name = "ZoomFullExtent1", Type = typeof(Button))]

Button ZoomFullExtent12;

ZoomFullExtent12 = GetTemplateChild("ZoomFullExtent1") as Button;

if (ZoomFullExtent12 != null)
                ZoomFullExtent12.Click += ZoomFullExtent12_Click;


And then I added my click event

private void ZoomFullExtent12_Click(object sender, RoutedEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(
                    -118.1, 33.0, -116.9, 35.9);

            if (Map != null)
                Map.ZoomTo(displayExtent);
        }


The question I'm asking now is how?? So I'm planning on when I have sometime researching/looking at depth at the code/and reading what is going on. 

This made me think how do you take  button with a click event in a xaml file:

< Button x:Name="ButtonX" Click="ButtonX_Click" />

And make the ButtonX_Click event handler/function live in a different code behind cs file.

Reference an event handler from another cs file in this xaml file (for example, this button is from XX.xaml file, and I have an event handler function saved in YY.cs)?

Lots to learn.

Thanks
0 Kudos