User-defined symbol in ArcGIS API for Silverlight is called in C #
1. Create the Help class, where the Application.loadcomponent parameter/tel.jsyd.fileimport;component/themes/symbol.xaml is the custom Symbol location
Public classSymbolhelper {StaticSymbolhelper () {ResourceDictionary rd=NewResourceDictionary (); Application.loadcomponent (Rd,NewUri ("/tel.jsyd.fileimport;component/themes/symbol.xaml", urikind.relative)); Application.Current.Resources.MergedDictionaries.Add (RD); } Public StaticSymbol Getcommonsymbol (stringkey) { if(Application.Current.Resources.Contains (key)) {ObjectSymbol =Application.current.resources[key]; returnSymbol asSymbol; } return NULL; }}View Code
2. Custom symbol
<ResourceDictionaryxmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"XMLNS:ESRISB= "Clr-namespace:esri." Arcgis.client.symbols;assembly=esri. Arcgis.client "> <Esrisb:fillsymbolx:name= "Currentprojectsymbol"BorderBrush= "Green"borderthickness= "2"> <Esrisb:FillSymbol.Fill> <SolidColorBrushColor= "Green"Opacity= "0" /> </Esrisb:FillSymbol.Fill> </Esrisb:fillsymbol> <Esrisb:fillsymbolx:key= "Currentprojectflickingsymbol"> <esrisb:FillSymbol.ControlTemplate> <ControlTemplateXMLNS:VSM= "Clr-namespace:system.windows;assembly=system.windows"> <Grid> <vsm:VisualStateManager.VisualStateGroups> <Vsm:visualstategroupx:name= "CommonStates"> <vsm:visualstatex:name= "MouseOver"> <Storyboard> <DoubleAnimationBeginTime= "0"Storyboard.TargetName= "Element"Storyboard.TargetProperty= "(shape.opacity)" to= "0.75"Duration= "00:00:01"RepeatBehavior= "Forever"/> </Storyboard> </vsm:visualstate> <vsm:visualstatex:name= "Normal"> <Storyboard> <DoubleAnimationBeginTime= "0"Storyboard.TargetName= "Element"Storyboard.TargetProperty= "(shape.opacity)" to= "0.75"Duration= "00:00:02"RepeatBehavior= "Forever"/> </Storyboard> </vsm:visualstate> </Vsm:visualstategroup> </vsm:VisualStateManager.VisualStateGroups> <Pathx:name= "Element"Fill= "Green"Opacity= "0.15"Stroke= "Green"strokethickness= "2"></Path> </Grid> </ControlTemplate> </esrisb:FillSymbol.ControlTemplate> </Esrisb:fillsymbol></ResourceDictionary>
View Code
Called in 3.c#
if (this. isplotcurrent) this. Plot.Graphic.Symbol = Symbolhelper.getcommonsymbol ("currentprojectsymbol");
View Code
User-defined symbol in ArcGIS API for Silverlight is called in C #