Canvas.SetLeft not working?
I'm trying to store the positions of all UI elements in a container. It seems to work fine. However, when I animate the UI elements and try to move them back to their original positions nothing happens. I am storing the position state like this :
Dictionary<string, Point> uiLocations = new Dictionary<string, Point>();
foreach (FrameworkElement element in this.Children)
{
if (!uiLocations.ContainsKey(element.Name))
{
uiLocations.Add(element.Name, new Point(Canvas.GetLeft(element), Canvas.GetTop(element)));
}
}
And after animating the elements to a different position I am attempting to restore the original locations like this:
foreach (FrameworkElement element in this.Children)
{
if (uiLocations.ContainsKey(element.Name))
{
Canvas.SetTop(element, uiLocations[element.Name].Y);
Canvas.SetLeft(element, uiLocations[element.Name].X);
}
}
Nothing happens, however. None of the elements change position. Any suggestions? I suppose I could use a TranslateTransform to get the elements to change position, but this seems rather combersome.
Any suggestions would be appreciated!

