Simple WPF Page Transitions
Introduction / Background
I have a little side project that I am working on which has multiple pages of information that need to be displayed, and I wanted a slicker way to transition between pages (UserControl
s) than just popping them into and out of existence (bad for the eyes).
My desire was to have better looking transitions, and this lead me to develop a very simple control library with several animations built in for more elegant page switches.
The following page transition types are currently included in this version of the control:
Fade
Slide
SlideAndFade
Grow
GrowAndFade
Flip
FlipAndFade
Spin
SpinAndFade
The control itself is very simple... it consists of a UserControl
(PageTransition
), which contains all of the translation logic. Inside this control, there are several animations in the UserControl.Resources
tag, defining all of the available animations. There is also an enum (PageTransitionType
) which is mapped as a DependencyProperty
that defines which animations are available to the users of the control.
Fade
Slide
SlideAndFade
Grow
GrowAndFade
Flip
FlipAndFade
Spin
SpinAndFade
Using the code
Using the PageTransition
control is easy... you just drop the control onto your WPF window (or type it in, using the XAML editor), which will then look something like this
<pageTransitions:PageTransition Name="pageTransition" Margin="25" TransitionType="Fade" />
Remember to set the TransitionType
property to one of the available values (in the list above), which will determine the type of animation that is displayed.
Don't forget to add the namespace of the WpfPageTransitions
project/classs in your window/control declaration!
At this point you can make a page change by referencing the PageTransition
control on your window and doing something like this in your code-behind:
NewPage newPage = new NewPage();
pageTransition.ShowPage(newPage);
Points of Interest
An interesting quirk that I came across when doing the animation for the slide-in/out, is that using the TranslateTransform
for sliding controls in and out of the window area doesn't appear to work correctly. I wasn't really looking for the slide-in/out feature, so I kind of skipped investigating the issue... If anyone has a sample they want to post of using TranslateTransform
to move the control around, that would be great.
History
First revision
发表评论
BYPmPi pulp fiber suspension, transported towards the pulp suspension into a network of institutions, right into a fiber network in the wet state and then into
U6uHSN There may be noticeably a bundle to find out about this. I assume you made certain nice points in features also.
JnAE2j Thanks for sharing, this is a fantastic blog post.Thanks Again. Will read on
hOrVq7
nkUqoN What as Happening i am new to this, I stumbled upon this I ave found It absolutely helpful and it has helped me out loads. I hope to contribute & aid other users like its helped me. Good job.
QNaE2x Pretty section of content. I just stumbled upon your weblog and in accession capital to claim that I get
u7iYmi Im obliged for the blog.Much thanks again. Great.
uIalYE Im thankful for the article post.Thanks Again. Really Cool.
tb2FpP I'm still learning from you, but I'm improving myself. I certainly love reading all that is written on your blog.Keep the aarticles coming. I loved it!
Vhe8qr Excellent read, I just passed this onto a colleague who was doing some research on that. And he actually bought me lunch since I found it for him smile Thus let me rephrase that: Thanks for lunch!
JjnKtD Hi my friend! I want to say that this article is amazing, great written and come with almost all vital infos. I'd like to peer more posts like this .
E9EDzy great issues altogether, you simply received a new reader. What might you suggest in regards to your put up that you made some days in the past? Any certain?
mEIhXJ F*ckin' remarkable things here. I'm very glad to see your article. Thank you a lot and i'm having a look forward to touch you. Will you kindly drop me a e-mail?
D4h3Nx There is obviously a lot to know about this. I assume you made some good points in features also.
SueuGV excellent issues altogether, you just gained a emblem new reader. What could you recommend in regards to your publish that you simply made some days in the past? Any sure?
v1EPJI Very neat blog post.Much thanks again. Fantastic.
trjstE A round of applause for your blog post.Really thank you! Great.
2n01xo I really enjoy the article.Thanks Again. Will read on...
OBEVPI Thanks again for the blog post.Much thanks again. Want more.
q08KXj Thank you for your blog post.Much thanks again. Great.
iKPAU6 Looking forward to reading more. Great blog.Really thank you!
IsTSLA Thanks a lot for the article post.Much thanks again. Want more.
GPUGLV Muchos Gracias for your blog article.Really thank you! Will read on...
S56W89 Thanks-a-mundo for the post.Much thanks again.
pwnOHE This is one awesome blog. Awesome.
ME1Tgh Appreciate you sharing, great article post.Really looking forward to read more. Really Cool.
v0EDPv Thanks for the post. Want more.
ft25Py Muchos Gracias for your blog article. Really Cool.
w05Fzl I appreciate you sharing this blog. Great.