Dynamically changing the direction using TransitionPresenter

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 10 years ago by Bob Ryan
Avatar
Product Version: WPF Studio v9.1.4.5

I have an application that is wizard-like (but not your wizard) that uses Windows' NavigationWindow and has several Pages. I am using the TransitionPresenter for each page like this:

<Page x:Class="myApp.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
Title="Foo" WindowTitle="Foo">

<shared:TransitionPresenter x:Name="transitionPresenter">
<shared:TransitionPresenter.Transition>
<shared:BarWipeTransition Direction="Forward" />
</shared:TransitionPresenter.Transition>

<Grid>
...stuff
</Grid>

As I navigate from page to page, the BarWipe transition draws left to right. However, I need a way to dynamically change Direction="Backward" when I am backing up. I tried to do this programatically in the page's load method - but to no avail.

This is built into your wizard but I am not using those classes. How to I change this programatically or via data binding?

Comments (5)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We programmatically toggle the setting of the TransitionPresenter.DefaultMode property based on whether we are moving forward or backward. We do this right before setting the new content (in our case a WizardPage).


Actipro Software Support

Posted 10 years ago by Bob Ryan
Avatar
I understand what you are saying, but this isn't happening for me. In my application, I use a NavigationWindow with Page1-Page4. Remember, this is NOT your wizard control, but a standard Windows NavigationWindow.

For each page's xaml, I embedded a grid control and various child controls within a <TransitionPresenter> as I indicated in the root thread. In each page's xaml, Direction=Forward.

Each page has one or more buttons that allow me to navigate forward or backward to a page. And, for each of these pages, I have a page Loaded event handler, where I reset the DefaulDirection=TransitionDirection Backward if we are moving backwards (via c# code). However, this never changes anything --> direction is always the default of forward.

My question, is why doesn't the Page_Loaded event supersede the xaml? Alternatively, is there a way I can change the Direction={DynamicResource xxxx}" binding to work?
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you are setting a Direction on the Transition then the TransitionPresenter.DefaultDirection will not override it. The DefaultDirection is only used when you don't set a Transition.Direction.

But regardless, you want to use the mode here as I said. I believe if you set TransitionPresenter.DefaultMode to In, it will use your direction setting. If you set the DefaultMode to Out, it should flip the direction around automatically for you.


Actipro Software Support

Posted 10 years ago by Bob Ryan
Avatar
If I removed the direction from the xaml, the default is 'forward'.

If I change my page's load to:
private void Page_Loaded(object sender, RoutedEventArgs e)
{
   transitionPresenter.DefaultDirection = ActiproSoftware.Windows.Media.Animation.TransitionDirection.Backward;
}
It never changes (it always sweeps forward). If needed, I can provide a base sample to show this.
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Bob,

I think you may be doing something wrong somewhere. The default of the transitions' Direction property is Default, which uses the TransitionPresenter.DefaultDirection. I can show it with this simple test.

Make a new Window called Window1 and put this as content:
<DockPanel>
    <Button DockPanel.Dock="Top" Content="Test" Click="Button_Click" />
    <shared:TransitionPresenter x:Name="transitionPresenter">
        <shared:TransitionPresenter.Transition>
            <shared:BarWipeTransition />
        </shared:TransitionPresenter.Transition>
    </shared:TransitionPresenter>
</DockPanel>
In Window1.cs do this (wire up Window.Loaded event to handler below too):
private int index;
private Brush[] brushes = new Brush[] { Brushes.Red, Brushes.Green };

private void Window_Loaded(object sender, RoutedEventArgs e) {
    transitionPresenter.DefaultDirection = ActiproSoftware.Windows.Media.Animation.TransitionDirection.Backward;
}

private void Button_Click(object sender, System.Windows.RoutedEventArgs e) {
    transitionPresenter.Content = new Border() { 
        Background = brushes[index++ % 2]
    };
}
You'll see the transition work backwards via the DefaultDirection setting, as expected. Maybe your Load handler wasn't being hit?


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.