Hi. I'm using a ControlTemplate to style map objects:
<ControlTemplate x:Key="EndPointStyle"> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"> <Storyboard> <DoubleAnimation BeginTime="00:00:00" Storyboard.TargetName="StateEllipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1" Duration="0:0:0.1" /> </Storyboard> </VisualState> <VisualState x:Name="MouseOver"> <Storyboard> <DoubleAnimation BeginTime="00:00:00" Storyboard.TargetName="StateEllipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1.1" Duration="0:0:0.1" /> </Storyboard> </VisualState> <VisualState x:Name="Working"> <Storyboard RepeatBehavior="Forever"> <DoubleAnimation BeginTime="0" Storyboard.TargetName="StateEllipse" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleX)" From="1" To="3" Duration="00:00:01" /> <DoubleAnimation BeginTime="0" Storyboard.TargetName="StateEllipse" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleY)" From="1" To="3" Duration="00:00:01" /> <DoubleAnimation BeginTime="0" Storyboard.TargetName="StateEllipse" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="10" Duration="00:00:01" /> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Ellipse RenderTransformOrigin="0.5,0.5" x:Name="StateEllipse" Fill="{Binding Symbol.Color}" Width="{Binding Symbol.Size}" Height="{Binding Symbol.Size}"> <Ellipse.RenderTransform><ScaleTransform /></Ellipse.RenderTransform> </Ellipse> <Rectangle RenderTransformOrigin="0.5,0.5" Width="{Binding Symbol.Size}" Height="{Binding Symbol.Size}"> <Rectangle.Fill><ImageBrush ImageSource="{Binding Symbol.Image}"></ImageBrush></Rectangle.Fill> </Rectangle> <Grid Margin="-200,-16,-200,0" MaxWidth="400" x:Name="SymbolText" HorizontalAlignment="Center> <TextBlock Foreground="Black" FontWeight="Bold" Text="{Binding Symbol.Text}" /> </Grid> </Grid> </ControlTemplate>
Map object is created like this:
var ct = _styles[TemplateName] as ControlTemplate; if (ct != null) { ct.LoadContent(); var icon = IconManager.GetImageByName(ImageName, false); Symbol = new StateMarkerSymbol(this) { Size = icon.PixelHeight, Image = icon, ControlTemplate = ct, }; }
Is there any way to change object visual state to "Working" from c# code ?
There is no easy way to change the symbol visualstates from code.
The problem being that the underlying UI element under a graphic is hidden.