Select to view content in your preferred language

Losing the focus of the Tool..?

1129
2
07-26-2010 11:35 AM
JoshV
by
Regular Contributor
Hi All-

I added the exact XAML and C# used in the samples for the Toolbar sample.  It works fine.  I then added the code below that came from the UtilitySample (Measure Button) and when the website loads I can select the Measure Button and get measurements by clicking on the map.  Then if I select a Tool on the Toolbar (Zoomin, Zoomout, etc) they will work just fine BUT if I select the Measure Button after using those tools on the Toolbar the focus is still on the Toolbar tools.  The only way I can get the Measure Button to get focus is to select the Measure Button, then select the Zoomout, then select Measure again.  Strange..

Can someone help me here?  Attached is my XAML.
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
The problem is that when you select the 'ZoomIn' button and then the 'Measure' button, the 2 tools are active and are listening to map click event (==> random result depending on event order).

When you click on the measure tool you need to disable the other tools.

Example : add this code:
 
private void DisableDrawObject(object sender, RoutedEventArgs e)
{
MyDrawObject.IsEnabled = false;
}


And call it when the user clicks the measure button:
                    <Button Style="{StaticResource MenuItem}"  Click="DisableDrawObject"                           
                            Content="Measure"  >
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <esriBehaviors:MeasureAction                                  
                                    AreaUnit="SquareMiles"
                                    DisplayTotals="True"
                                    DistanceUnit="Miles"
                                    MapUnits="DecimalDegrees"
                                    MeasureMode="Polygon"                                   
                                    FillSymbol="{StaticResource DefaultFillSymbol}"
                                    TargetName="MyMap"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
0 Kudos
JoshV
by
Regular Contributor
The problem is that when you select the 'ZoomIn' button and then the 'Measure' button, the 2 tools are active and are listening to map click event (==> random result depending on event order).

When you click on the measure tool you need to disable the other tools.

Example : add this code:
 
private void DisableDrawObject(object sender, RoutedEventArgs e)
{
MyDrawObject.IsEnabled = false;
}


And call it when the user clicks the measure button:
                    <Button Style="{StaticResource MenuItem}"  Click="DisableDrawObject"                           
                            Content="Measure"  >
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <esriBehaviors:MeasureAction                                  
                                    AreaUnit="SquareMiles"
                                    DisplayTotals="True"
                                    DistanceUnit="Miles"
                                    MapUnits="DecimalDegrees"
                                    MeasureMode="Polygon"                                   
                                    FillSymbol="{StaticResource DefaultFillSymbol}"
                                    TargetName="MyMap"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>


Thanks Dominique.  That worked
0 Kudos