I was able to use this technique to do what I wanted, which is to prevent back navigation while hiding a control that slides in and out of the window. By default, the control's visibility is collapsed. Storyboards are used to control when it becomes visible or collapsed. In XAML, inside the Storyboard:
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ControlScroller" Storyboard.TargetProperty="(UIElement.Visibility)">
<ObjectAnimationUsingKeyFrames.KeyFrames>
<DiscreteObjectKeyFrame KeyTime="00:00:00">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames.KeyFrames>
Then in the page's code:
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
if(ControlScroller.Visibility == Visibility.Visible && StoryboardHideControlSlider.GetCurrentState() != ClockState.Active)
{
StoryboardHideControlSlider.Begin();
ContentGrid.IsHitTestVisible = true;
e.Cancel = true;
}
}
Note: In the Storyboard that hides the ContentScroller (which is a grid), the KeyTime is set to "00:00:01" because I want it to remain visible while it is sliding (and fading) out of view.
Note 2: The reason StoryboardHideControlSlider.GetCurrentState() != ClockState.Active
is included in the if statement is because if the user hits the back button twice and the Storyboard hasn't completed it will run again. This prevents the backbutton cancelling navigation back to the previous page. So in other words, if the Storyboard is active, the code "knows" that the user has already initiated hiding it and intends to navigate back to the previous page. (Well, at least that's behavior they're going to get...and they won't see the animation twice)!