Animate moving a usercontrol to new grid position - silverlight

I have a simple Silverlight (v5) Grid with a fixed number of rows and columns. On this grid, I'm positioning several UserControls (called myControl in this example) at specific "grid coordinates" e.g. row 2, column 1.
Occasionally, I need to move a myControl to a new grid position; I currently do this by
Grid.SetColumn(myControl, newColumn);
Grid.SetRow(myControl, newRow);
.. and this all works fine, myControl is moved to the new coordinates.
Just purely for eye candy, I'd like to animate myControl when it moves, so that it "slides" from the old grid position to the new one rather than just appearing. Is there an easy/quick way to do this?

For handling layout changes within an element to display a smooth transition FluidMoveBehavior is generally the option you would be looking for. While it won't animate things like size or visibility, it is however specifically for animating the offset of a child element moved around a parent container.
Glad you found your answer. Cheers

Related

WPF animated stack panel

I'm in the process of creating an ItemsControl that will have something similar to a StackPanel for its ItemsPanel. However, I want the user to be able to rearrange items in the panel, and have them animate to their final positions like this:
I've done some searching, and a lot of the examples I have found that do something similar, implement the animations by setting the desired position of all items to 0,0 and applying a RenderTransform storyboard in the Panel.ArrangeOverride method to offset each item vertically.
Whilst this works, is this the correct way to be doing it? Doesn't this mean the controls won't take part in normal layout as they're all set to 0,0?
Will this have side effects?
I was wondering if I should use the above method for the animation, and then when the animation ends, do another final invalidation of the arrange layout, but this time using actual positions instead of render transforms?

Animate wrappanel items repositioning

I'm trying to create an animation like the text zoom animation that exists in the wii news channel. See this at 0:45 to an example.
My current code is to take a string, split it into a string[] between the spaces, create a textblock for each word, and inserting it into a List of TextBlocks.
After that, I need to put it as an ItemsSource of a WrapPannel, and change the fontsize of each textblock to generate the zoom effect. This will make the correct positioning, but without any animation.
I also searched about FluidMoveBehavior, but I don't know how to apply this to my situation.
How can I animate the repositioning of the items into the wrap panel? My approach is the best way to do that?

WPF: How to achieve visual print of UIElement into multiple pages?

I have several controls in a ScrollViewer which when printed should span multiple pages both horizontally and vertically. My current solution uses a series of scrolls (both in horizontal & vertical direction) to achieve the printing.
For this implementation to work the content of the ScrollView needs to be disassociated and added to a new ScrollViewer (the new instance of ScrollViewer is adjusted to PrintWidth and Height to achieve the print objective), as a result the original view will be emptied. To overcome this problem, I have tried Cloning the entire ScrollViewer, but this seems to fail with bindings - DataGrid is displayed empty in the cloned visual.
Is there any other approach where the visual elements can be printed, or, are there any other approach (perhaps using VisualBrush) to achieve the objective of multi page print?

Silverlight zindex with dynamically added controls

I have grid with some textboxes and an image which goes out of grid boundaries and I add this grids dynamically in my code to another grid.
I want to have my image on top of all the rest of the grids. Unfortunately each grid I add to the root grid will hover over my previous grid image.
Could you please suggest anything?! I have tried with zindex and it did not work in my case.
What I am doing wrong?
ZIndex only works for the immediate children of a panel-derived container (Grid, Canvas, Stackpanel etc). Otherwise it is down to the order they exist in the visual tree (i.e. the last one gets displayed on top).
If you have nested objects you simply need to think about the order they are added. The simplest way to do this is have two top level grids/panels, the first contains everything else and the last containing just the dynamically added children.
This way whatever you put in the second grid will always be on top of all other items (in the first grid/container).

How can I animate a transition when moving a child from one panel to another in Silverlight

I would like to animate a transition when moving content between two panels. I am getting a bit map image of a detail record and docking it as a thumbnail in the panel below. The docking area is in a footer grid and the content detail is in another grid that sits above the dock area (the dock and the main content area live in separate rows of the root layout control - another grid).
I have tried implementing this with a ScaleTransform and a TranslateTransform, simultaneously shrinking the image and moving it towards the footer control. When it moves into the footer control, it gets clipped even though the image Canvas.ZIndex property is set to a very high number. Eventually the thumnbail will need to be a child of a StackPanel that sits inside the footer grid.
Thanks for your consideration and help.
I had a similar problem (clipping) with a WPF animation I had. The problem was that the owner of the animation needed to be a parent of both containers for the animation to work (in my case I made it the actual window holding the containers).
Without any code, I can't see if that is your problem, but I thought I would throw it out there.
You can see my code where I animate moving from one container to another here:
http://wiassistant.codeplex.com/sourcecontrol/changeset/view/36638?projectName=WIAssistant#924851
(See the AnimatePaneBox method at the bottom of the file.) This may or may not be useful to you.
I've done something similar by creating a Canvas that sits over the top of both containers, using a WritableBitmap (if necessary) to create a rendering of the object that you're moving and attach it to that Canvas, animate the bitmap (translate, scale, opacity, whatever), and then pop the new object in under it at the end of the animation. It can be brittle if your controls need to be able to move or resize, but in most of my circumstances it's been a reliable hack.

Resources