Skip to Content
Programming WPF, 2nd Edition
book

Programming WPF, 2nd Edition

by Chris Sells, Ian Griffiths
August 2007
Intermediate to advanced
864 pages
25h 52m
English
O'Reilly Media, Inc.
Content preview from Programming WPF, 2nd Edition

Transition Animations

Sometimes it can be useful to use animations to ease the transition between one part of the user interface and another. Many user interfaces present multiple different contexts and allow the user to navigate between them. For example, a modal dialog presents a different context from the main user interface. In navigation-style applications, each page is its own context. Most applications switch between these contexts more or less instantaneously. However, we can provide a smoother experience for the user if we animate the transition from one part of the UI to another (e.g., fade).

Unfortunately, the current version of WPF does not provide any automatic support for transition animations. For example, you can't simply supply a NavigationWindow or Frame with an animation to use when moving from one page to another. You need to do a little more work.

To provide transition animations in a navigation application, we need to handle both the Navigating and the Navigated events. In the Navigating event handler, we can capture a copy of the current page's appearance in the form of a VisualBrush. In the Navigated event, we can use this to provide a transition animation.

Tip

We can't handle it all in a single event. In the Navigated event handler, it's too late to get hold of the old page. And, in the Navigating handler, it's too early to start the animation: we don't yet know whether navigation will definitely occur, because it may be cancelled.

Example 16-35 shows the markup ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Practical WPF Charts and Graphics

Practical WPF Charts and Graphics

Jack Xu
Illustrated WPF

Illustrated WPF

Daniel Solis
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9780596510374Errata Page