Select to view content in your preferred language

Retrieve Value From MapTip

856
3
04-25-2011 12:07 PM
PaulVepraskas
Frequent Contributor
Thanks in advance for any help, Im sure this is super easy but I cannot seem to get it to work...

I am trying to extract a value from a MapTip, I have buttons created in the MapTip that call a function and all I am trying to do at the moment is basically get an alert on the value from the Tip?

The xaml
<esri:FeatureLayer.MapTip>
                    <Grid esri:GraphicsLayer.MapTipHideDelay="00:00:01.5">
                        <Border CornerRadius="10" BorderBrush="#FF222957" BorderThickness="3" Margin="0,0,35,35">
                        <Border.Background>
                            <LinearGradientBrush EndPoint="1.038,1.136" StartPoint="0.015,0.188">
                                <GradientStop Color="#c98c63"/>
                                <GradientStop Color="#ff6600" Offset="0.946"/>
                            </LinearGradientBrush>
                        </Border.Background>
                        <Border.Effect>
                            <DropShadowEffect ShadowDepth="10" BlurRadius="14" Direction="300" />
                        </Border.Effect>
                            <StackPanel Margin="7">
                                <TextBlock x:Name="maptipTitle" Text="{Binding [ID]}" FontWeight="Bold" Foreground="Black"/>
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="Image: " Foreground="Black" />
                                    <TextBlock x:Name="maptipBind" Text="{Binding [ID]}" Foreground="Black" />
                                    <Button x:Name="SelectButton" Content="Select" Width="75" Height="24" VerticalAlignment="Center" Click="ExecuteButton_Click" Margin="5,0,5,0" Cursor="Hand"/>
                                    <Button x:Name="EditButton" Content="Edit" Width="75" Height="24" VerticalAlignment="Center" Click="ExecuteButton_Click" Margin="5,0,5,0" Cursor="Hand"/>
                                </StackPanel>
                           </StackPanel>
                    </Border>
                    </Grid>
                </esri:FeatureLayer.MapTip>
The CS
private void ExecuteButton_Click(object sender, RoutedEventArgs e)
        {
            _signCode = maptipBind.Text; 
            TextBlock.Text = string.Format("WHAT AM I DOING WRONG" + _signCode);
        }


I know that buttons work and that me "TextBlock.Text" is working, but I cant seem to extract a value from the map tip?  Any advice?

Thanks
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
0 Kudos
PaulVepraskas
Frequent Contributor
Thank you for your help,

I started a new project with that maptip, and used your suggested code.  I swapped the "System.Diagnostics.Debug.WriteLine" with "MessageBox.Show"  I expected to see the name of the city returned in the Message, but All I get is:

"Another way of accessing this control'{0}'" MyCityName

What I want is to get the binded value in the MyCityName textblock (for example Salt Lake City) not the name of the textblock?

does that make sense?
0 Kudos
PaulVepraskas
Frequent Contributor
Got it...

I changed this...
var name = (((mapTip as Border).Child as StackPanel).Children[0] as TextBlock).Name


To this
var name = (((mapTip as Border).Child as StackPanel).Children[0] as TextBlock).Text
0 Kudos