JenLink

Labeling a graphic using the ArcGIS Runtime for WPF

Discussion created by JenLink on Jan 21, 2014
Latest reply on May 14, 2014 by MBranscomb-esristaff
Hello,
I'm looking for a way to label a graphic using the ArcGIS Runtime for WPF. Previously, I accomplished this by creating a graphic that referenced a MarkerSymbol created in XAML. A TextBlock was used within the MarkerSymbol ControlTemplate to bind to an attribute of the graphic. The latest ArcGIS Runtime does not appear to support this. Could someone point out the correct objects I should be using to accomplish this? I need to dynamically set the label text associated with the graphic.
Thanks!
Jen

XAML

<Grid x:Name="LayoutRoot" Margin="0,0,-430.4,0.4">
        <Grid.Resources>
            <esri:MarkerSymbol x:Key="labelSymbol_10_1">
                <esri:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Grid>
                            <StackPanel Orientation="Horizontal">
                            <Ellipse Width="12" Height="12" Fill="Red" HorizontalAlignment="Left" VerticalAlignment="Top" />
                            <TextBlock Text="{Binding Attributes[NAME]}" FontSize="12" FontStyle="Oblique" FontWeight="Bold"></TextBlock>
                            </StackPanel>
                        </Grid>                        
                    </ControlTemplate>
                </esri:MarkerSymbol.ControlTemplate>
            </esri:MarkerSymbol>
        </Grid.Resources>


C#
 
ESRI.ArcGIS.Client.GraphicsLayer graphicsLayer10_1 = new ESRI.ArcGIS.Client.GraphicsLayer();

                ESRI.ArcGIS.Client.Symbols.MarkerSymbol marker10_1 = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol()
                {Size = 10, Style = ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Circle, };

                ESRI.ArcGIS.Client.Graphic graphic10_1 = new ESRI.ArcGIS.Client.Graphic()
                {
                    Geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint()
                    {
                        X = -10764928.3045,
                        Y = 4985563.0066,
                    },
                    Selected = false,
                    Symbol = LayoutRoot.Resources["labelSymbol_10_1"] as ESRI.ArcGIS.Client.Symbols.MarkerSymbol,
                };

                graphic10_1.Attributes.Add("NAME", "Here I Am");
                graphicsLayer10_1.Graphics.Add(graphic10_1);
                myMap10_1.Layers.Add(graphicsLayer10_1);

Outcomes