How to make Map.Center change instantly - silverlight

I have a map control with its center bound to a GeoCoordinate property in the viewmodel.
The map's center properly changes whenever the property changes.
By default, the map has a animation for changing its view (it gradually moves to the new location).
However, I do not want this animation.
I would like the map to instantly center on the new location.
I have already set the animation of the map: AnimationLevel="None", but it didn't seem to change anything.
The animation normally looks really nice, however, this app only deals with locations in a very small view. With small changes to the map's center, the animation just makes everything look like its shaking and it takes too long to finish.
As always, please let me know if I need to clarify anything.

I had have related problem. Try to set AnimationLevel to something else and than set back to None

Related

Why do `TextField`s sometime include its parent `Container`s and sometimes not when they start being edited?

I have a TextField inside a Container. The Container is in the SOUTH of a Form (BorderLayout). The Form's CENTER Contains a scrollable BoxLayout.y() Container
When the bottom TextField is tapped on Android, the keyboard is shown. Sometimes, it cuts the TextField's parent Container up to the TextField's bottom, sometimes it doesn't. When it does cut it, the Form's CENTER also gets pushed up, and the Toolbar disappears. I am trying to make sure that calling the keyboard never cuts the parent Container and that the CENTER Container doesn't get pushed up
Is there a way to guarantee that the parent Container is always shown so that it doesn't get cut?
Example of an instance when it doesn't get cut:
Example of an instance when it does get cut. Notice Toolbar is gone and CENTER Container is pushed upwards:
Generally this is really hard to tune positions for keyboard. We try to make it seamless but there are points where this is pretty difficult to control. Especially with a south placed text field which is static (not scrollable).
If you can isolate a test case that shows misbehavior here we might be able to fine tune the logic a bit.
Solution to prevent this consists in setting the Form's setFormBottomPaddingEditingMode(true);. Easy fix! 👍

Canvas - dynamic drawing and managing shapes

I'm trying to make an application which allows the user to draw shapes to the canvas. Once drawn, I would like for the user to be able to select, move, resize, basically manipulate the shapes in any which way.
I have done something similar in XNA and that was quite easy due to the fact that there was a draw loop. In Silverlight there is no such thing as far as I understand and I am having trouble figuring out how to manage the objects on the canvas. As in what is the best way to manage the canvas' children collection to ensure appropriate response of the UI to what the user does.
Most examples out there are pretty basic and do not go anywhere near this kind of thing. I would be grateful if somebody who has done this before could tell me how they approached the problem.
Thinking about it for a while I think I figured out how it works.
There is a draw loop for the canvas, which is the draw loop of the top level parent container which it lives on.
The difference with XNA I guess is that the collection of items to draw on the canvas doesn't need to be explicitly drawn, since the canvas takes care of drawing its children automatically.
So, what I need is some way to hold on to any object I add to the canvas' children... I can then update the objects drawing properties and the changes will be reflected in the canvas next time it refreshes.
I guess a dictionary of some sort in which to store the items I put in the list might be best...?
Not a finished answer yet, but I guess I understand half of it now.

Touch Manipulated Element keep behind other elements

I'm currently playing with touch gesture support and I wired up an element that can be zoomed in, rotated, etc through manipulationdelta. The elements container is a border however whenever i gesture the element it moves across the screen and I want to keep it inside the border where they can only use that area of the screen to manipulate the element. Any ideas as to how to accomplish this? Thanks!
Seeing how nobody has replied, I'll just say I think I've come up with a workaround by hosting a window inside a grid... that way the manipulation is always bound to the child window.

Reversing an animation in Silverlight on button press or any other event

How would I reverse a double animation in Silverlight on an event? For example, lets say I have an ellipse as a path and I am moving a shape along this path in an infinite loop. If I press a button, I want to reverse the direction of the spin (clockwise <-> counterclockwise).
To be more specific, I am using the PathListBox object that is new in SL4. It has a start property from 0 to 100% (double 0 - 1) that will place the first item at the specified location along the path. By animating this property from 0 to 1 and 1 to 0, I can make an object spin clockwise and counter clockwise.
Lets say I have a button and on the button press, I want to reverse the direction. How do I go about doing it? I've tried pausing the animation and swapping the To and From values of the animation and resuming it, but this causes the animation to jump. So if its at "3 o'clock" on the ellipse, it jumps to "9 o'clock" and goes backwards from there. I tried doing something like setting the storyboard's CurrentTime property to "Duration - CurrentTime", but that property doesn't seem to be settable.
So, in conclusion, any ideas about how to reverse an animation on demand?
PS: I know there is a PathListBoxUtils that provides scroll behaviors for PathListBox, but that doesn't quite implement what I want. Or to put it another way, I am looking to modify the PathListBoxUtils to have an infinitely rotating, reversible carousel rather than scrolling one item at a time.
Ok, the way I got it working was by pausing the animation, swapping the To and From values, and using the Seek method to move the animation forward by a set amount. The amount I needed it to move forward is "Duration.TimeSpan() - GetCurrentTime()", but accessing Duration seems to throw an exception (Operation not valid for the current state of the object).
For now, I just hard coded the Duration value for a test and seems to be working fine. I guess for a real implementation the Duration can be bound to some value and the calculation can use that value too.

Center a Silverlight modal popup in a canvas that is larger than the screen

I currently have a Silverlight canvas that exceeds the viewable area of the screen (I'm letting the users drag the viewable areas around to navigate). I'm trying to display a modal popup that always shows up in the middle of the viewable area, and I can't seem to find any property that tells me what currently is on the screen. Basically if the user has panned down to the bottom and clicks something that causes a modal popup to appear it is stuck at the far top of the screen.
Any ideas anyone?
Thanks
~Steve
I don't think this is possible since the visibility isn't being surfaced. Perhaps with some fun JavaScript to figure out where the panning is?
Quite true. I wound up creating a holding canvas, making that full screen, and putting everything else as a child canvas within that. The modal popup now comes up in the holding canvas.
Gabriel Guimarães one works good.
App.Current.Host.Content.ActualHeight(and ActualWidth) does bring the browser size inside. Good for calculating position. And of course you can use LayoutUpdated on your main control to double check the sizes and resize stuff if need be.

Resources