用xaml写一个ControlTemplate。源码如下
<ControlTemplate
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:vsm="clr-namespace:System.windows;assembly=System.windows" >
<GrID
RendertransformOrigin="0.5,0.5"
Height="50"
WIDth="50">
<GrID.Rendertransform>
<transformGroup>
<Scaletransform x:name="scale" ScaleX="1" ScaleY="1" />
<Translatetransform X="-25" Y="-25"/>
</transformGroup>
</GrID.Rendertransform>
<vsm:visualstatemanager.VisualStateGroups>
<vsm:VisualStateGroup x:name="CommonStates">
<vsm:VisualState x:name="normal">
<Storyboard>
<DoubleAnimation BeginTime="0:0:0" Storyboard.Targetname="scale" Storyboard.TargetProperty="ScaleX" To="1" Duration="0:0:0.3" />
<DoubleAnimation BeginTime="0:0:0" Storyboard.Targetname="scale" Storyboard.TargetProperty="ScaleY" To="1" Duration="0:0:0.3" />
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:name="MouSEOver">
<Storyboard>
<DoubleAnimation BeginTime="0:0:0" Storyboard.Targetname="scale" Storyboard.TargetProperty="ScaleX" To="2" Duration="0:0:0.3" />
<DoubleAnimation BeginTime="0:0:0" Storyboard.Targetname="scale" Storyboard.TargetProperty="ScaleY" To="2" Duration="0:0:0.3" />
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:name="SelectionStates">
<vsm:VisualState x:name="Selected" />
<vsm:VisualState x:name="Unselected" />
</vsm:VisualStateGroup>
</vsm:visualstatemanager.VisualStateGroups>
<Image
HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="16"
WIDth="16"
Source="Images/sym.png"
/>
<Image
HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="24"
WIDth="24"
Source="Images/symout.png"/>
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="20"
WIDth="40"
margin="0,30"
FontWeight="Bold"
Foreground="Purple"
FontSize="9"
Text="mynumb"/>
</GrID>
</ControlTemplate>
改变其属性“生成 *** 作”为”嵌入的资源“(这个很重要)
定义一个类OnSymbol继承自MarkerSymbol
public class OnSymbol : MarkerSymbol
{
public OnSymbol(string username)
: base()
{
try
{
string key = "LS.PRJ2011.Tracker.OnlinSymbol.xaml";
Stream stream = typeof(OnSymbol).Assembly.GetManifestResourceStream(key);
string template = new StreamReader(stream).ReadToEnd();
//template = template.Replace("force1.png","force" + sType.ToString() + ".png");
//template = template.Replace("comp1.png","comp" + sComp.ToString() + ".png");
template = template.Replace("mynumb",username);
this.ControlTemplate = (ControlTemplate)XamlReader.Load(template);
}
catch (Exception ex)
{
MainPage.add_to_logger(ex);
}
}
}
然后,对于图层对象的Symbol就可以直接赋值OnSymbol 实例
tmpGraphic.Symbol = new OnSymbol(mobilename);
总结以上是内存溢出为你收集整理的arcgis api for silverlight自定义一个Symbol全部内容,希望文章能够帮你解决arcgis api for silverlight自定义一个Symbol所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)