WINXP SP3 + VS2010SP1 + Siverlight5 + API3.0my XML code:
<UserControl xmlns:esri="http://schemas.esri.com/arcgis/client/2009" x:Class="SL_TextSymbol.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<esri:SimpleMarkerSymbol x:Key="RedCircleSymbol" Color="Red" Size="12" Style="Circle" />
<esri:TextSymbol x:Key="MyTextSymbol">
<esri:TextSymbol.ControlTemplate>
<ControlTemplate>
<Border Background="White" BorderBrush="Black">
<TextBlock x:Name="MyInfo"
FontSize="{Binding Symbol.Size}"
Text="{Binding Symbol.Text}"
Foreground="Blue"
FontFamily="{Binding Symbol.FontFamily}"
HorizontalAlignment="Center" />
</Border>
</ControlTemplate>
</esri:TextSymbol.ControlTemplate>
</esri:TextSymbol>
</Grid.Resources>
<esri:Map x:Name="MyMap" WrapAround="True" Background="White">
<esri:ArcGISTiledMapServiceLayer ID="PhysicalTiledLayer"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
<esri:GraphicsLayer ID="MyGraphicsLayer" />
</esri:Map>
</Grid>
</UserControl>
My C# code:
using System.Windows.Controls;
using System.Windows.Media;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using ESRI.ArcGIS.Client.Projection;
using ESRI.ArcGIS.Client.Symbols;
namespace SL_TextSymbol
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
// one
Graphic graphic1 = new Graphic()
{
Geometry = new MapPoint(118, 35),
Symbol = LayoutRoot.Resources["RedCircleSymbol"] as Symbol
};
graphicsLayer.Graphics.Add(graphic1);
TextSymbol textSymbol1 = LayoutRoot.Resources["MyTextSymbol"] as TextSymbol;
Graphic graphicText1 = new Graphic()
{
Geometry = new MapPoint(118, 35),
Symbol = textSymbol1
};
textSymbol1.FontSize = 12;
textSymbol1.Foreground = new SolidColorBrush(Colors.Blue);
textSymbol1.Text = "one";
textSymbol1.OffsetX = -10;
graphicsLayer.Graphics.Add(graphicText1);
// two
Graphic graphic2 = new Graphic()
{
Geometry = new MapPoint(1800000, 50000),
Symbol = LayoutRoot.Resources["RedCircleSymbol"] as Symbol
};
graphicsLayer.Graphics.Add(graphic2);
TextSymbol textSymbol2 = LayoutRoot.Resources["MyTextSymbol"] as TextSymbol;
Graphic graphicText2 = new Graphic()
{
Geometry = new MapPoint(1800000, 50000),
Symbol = textSymbol2
};
textSymbol2.FontSize = 12;
textSymbol2.Foreground = new SolidColorBrush(Colors.Blue);
textSymbol2.Text = "two";
textSymbol2.OffsetX = -10;
graphicsLayer.Graphics.Add(graphicText2);
}
}
}
[ATTACH=CONFIG]21160[/ATTACH]I want "one" and "two". but "two" and "two".thanks!