Select to view content in your preferred language

MarkerSymbol Bindings to it's Graphic

900
2
03-08-2012 03:50 AM
jonataspovoas
Regular Contributor
Hi,

I'm build a coordinate search to my appication. To do so, I'm using the following MarkerSymbol, to show the coordinates and a image that represents the point.

<ResourceDictionary
    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">

    <esri:MarkerSymbol x:Key="MarcadorCustomizadoFerramentaCoordenadas" OffsetX="8" OffsetY="31">
        <esri:MarkerSymbol.ControlTemplate>
            <ControlTemplate>
                <StackPanel Orientation="Horizontal">
                    <Image Source="/ViewModel;component/RecursosGraficos/Imagens/marcadorCoordenadas.png"/>
                    <Border BorderBrush="Green" Background="White" BorderThickness="1">
                        <TextBlock Text="{Binding [Coordenadas]}" TextAlignment="Left" VerticalAlignment="Center" 
                                   FontFamily="Portable User Interface"/>
                    </Border>
                </StackPanel>
            </ControlTemplate>
        </esri:MarkerSymbol.ControlTemplate>
    </esri:MarkerSymbol>
    
</ResourceDictionary>


The problem in this code is that the Binding get no value. This Binding was originaly on a MapTip code on the GraphicsLayer, and there it works fine.

Does Anyone knows how to make it work as a Graphic Symbol?

This is how I set the Marker as Symbol of the Graphic:

private void AdicionaPontoNoGraficsLayer(MapPoint ponto)
{
    mapaEmExecucao.PanTo(ponto);

    Graphic bandeiraBuscaPorCoordenadas = new Graphic();
    bandeiraBuscaPorCoordenadas.Attributes.Add("Coordenadas",
                                                string.Format("X: {0}\nY: {1}",
                                                             Math.Round(ponto.X, 4),
                                                             Math.Round(ponto.Y, 4)));
    bandeiraBuscaPorCoordenadas.Geometry = ponto;
    bandeiraBuscaPorCoordenadas.Symbol = RecursosGraficos.RecursosGraficos.ObtemImagem(RecursosGraficos.RecursosGraficos.Imagens.MarcadorCustomizadoFerramentaCoordenadas);

    GraphicsLayer resultadoBuscaCoordenada = mapaEmExecucao.Layers["ExibePontosFerramentaCoordenadas"] as GraphicsLayer;
    resultadoBuscaCoordenada.Graphics.Add(bandeiraBuscaPorCoordenadas);
}
0 Kudos
2 Replies
jonataspovoas
Regular Contributor
Hi again,

I'm still trying to make it work, but now I'm trying a different approach:

I made now two graphics: one with the image, another with the text.

The image symbol is working well, but I now have the same problem I had on the text Field.

Here is the template I tried to build:

<ResourceDictionary
    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">

    <esri:TextSymbol x:Key="MarcadorTextualDaFerramentaCoordenadas">
        <esri:TextSymbol.ControlTemplate>
            <ControlTemplate>
                <TextBlock Text="What Goes here?"
                           FontFamily="Portable User Interface"
                           FontWeight="Bold"
                           FontSize="10"
                           Foreground="Red"/>
            </ControlTemplate>
        </esri:TextSymbol.ControlTemplate>
    </esri:TextSymbol>

</ResourceDictionary>


The problem in it is that I don't know what to bind the textblock to...
0 Kudos
DaveOrlando
Frequent Contributor
I had the same situation.

the binding is different for MapTips vs the custom symbol (control template). try adding 'Attributes' to the binding statement

Text="{Binding Attributes[AREANAME]}"


(any idea how to switch to a different attribute from codebehind based on a user selection?)


hope that helped
0 Kudos