0

I'm working on a Wizard-style application that has a panel on the right-hand side that changes size to reflect it's content (which would change to the content related to the current page). The panel consists of a ScrollViewer with a surrounding Rectangle that acts as a border. When the content within this panel is smaller than the available space given to it, the panel changes to the required size, aligned to the center of the available space. When the content within this panel is larger than the available space, the panel fills the space and the scrollbars show to scroll the content. The layout works like a charm and looks pretty good, but I want to do some animation when the content changes (as a result of the Wizard's page changing).

Basically, at the current time, changing the content within the panel instantaneously changes the width and height of the panel as required; however, it would be nice if I could make it so that the width and height change gradually (taking around half a second). The way I envision it is that the current content would fade out, then the panel would change size with the required animation, then the new content will fade in. I could figure out how to do this with a storyboard, but I just wondered if there was an existing control that does this?

Lee.J.Baxter
  • 495
  • 4
  • 12
  • In WPF, you'd do that by having an event trigger run a StoryBoard with two DoubleAnimations, one for height and one for width. I'm not sure what event you'd use, but for the rest there are a lot of examples around. – 15ee8f99-57ff-4f92-890c-b56153 May 10 '17 at 14:13
  • @EdPlunkett - If I had to code it myself, I'd do it in the code-behind and trigger the storyboard when I'd set a "CurrentContent" property. Of course, I'd need to acquire the current and new widths and heights to set the "From" and "To" properties of the 2 "DoubleAnimations". – Lee.J.Baxter May 10 '17 at 14:21
  • Yeah. One thing to look out for with doing storyboards in codebehind is that there's a target name resolution thing that comes up sometimes or always or... I don't know when/where/why, but [I know there's a workaround](http://stackoverflow.com/a/42662734/424129). Personally I find XAML easier to write, maintain, and reuse, but it's your thing. – 15ee8f99-57ff-4f92-890c-b56153 May 10 '17 at 14:35
  • XAML's also easier to get help with. The XAML-answer crowd around here isn't used to doing anything in codebehind and they get crotchety when they (OK, we) see it. – 15ee8f99-57ff-4f92-890c-b56153 May 10 '17 at 14:36
  • Good point! I must admit, XAML is easier as well if I can figure out how to do it. I used to use code-behind for everything (for some reason, I had XAMLphobia!), and soon grew to love XAML!!! – Lee.J.Baxter May 10 '17 at 15:57

0 Answers0