Hi,
How could i do DoubleAnimination over SymbolElement's SymbolSize property?
Thanks,
NNT
Hi NNT,
Unfortunately SymbolElement's SymbolSize isn't a dependency property, but as a workaround you can create a new dependency property that dispatch every change to the map element's one. E.g.:
In XAML:
<igMap:XamMap x:Name="xamMap1"> <igMap:XamMap.Layers> <igMap:MapLayer x:Name="MapLayer" IsAutoWorldRect="True" > <igMap:MapLayer.Reader> <igMap:ShapeFileReader Uri="Shapefiles/usa/usa_st" DataMapping="Name,Caption=STATE_NAME"/> </igMap:MapLayer.Reader> </igMap:MapLayer> <igMap:MapLayer x:Name="symbolLayer"> </igMap:MapLayer> </igMap:XamMap.Layers></igMap:XamMap>
In Code behind
1. The SymbolSize Dependency property
#region SymbolSize
public double SymbolSize{ get { return (double)GetValue(SymbolSizeProperty); } set { SetValue(SymbolSizeProperty, value); }}
public static readonly DependencyProperty SymbolSizeProperty = DependencyProperty.Register("SymbolSize", typeof(double), typeof(ButtonSymbol), new PropertyMetadata(0.0, OnSymbolSizeChanged));
private static void OnSymbolSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){ ((ButtonSymbol)d).OnSymbolSizeChanged((double)e.OldValue, (double)e.NewValue);}
private void OnSymbolSizeChanged(double oldValue, double newValue){ ((SymbolElement) xamMap1.Layers[1].Elements[0]).SymbolSize = newValue;}
#endregion
2. Create a SymbolElement at specific coordinates
var element = xamMap1.Layers[0].Elements.FindElement("Name", "Montana").ElementAt(0);
var origin = new Point(element.WorldRect.X + 0.5 * element.WorldRect.Width, element.WorldRect.Y + 0.5 * element.WorldRect.Height);var symbolElement = new SymbolElement { SymbolOrigin = origin, SymbolType = MapSymbolType.Diamond, SymbolSize = 10 };
xamMap1.Layers[1].Elements.Add(symbolElement);
Rect worldRect = xamMap1.Layers[1].WorldRect;worldRect.Union(symbolElement.WorldRect);xamMap1.Layers[1].WorldRect = worldRect;
3. Animate custom SymbolSize DP that changes to the SymbolElement's SymbolSize:
var sb = new Storyboard();
var animation = new DoubleAnimation();animation.To = 20;animation.Duration = TimeSpan.FromSeconds(2.0);animation.RepeatBehavior = RepeatBehavior.Forever;
Storyboard.SetTarget(animation, this);Storyboard.SetTargetProperty(animation, new PropertyPath(SymbolSizeProperty));sb.Children.Add(animation);sb.Begin();
Please let me knof if that works for you.
Regards,
Ivan Kotev