TransitioningContentControl - doesn't transition

Topics: Prism v4 - Silverlight 4
Jul 1, 2011 at 7:09 PM

I am attempting to use the TransitioningContentControl.  It works fine with prism navigation except it immediately removes the current content and animates the new one in.... always...

The first screen comes up (in the MainContentRegion), then the call below is made after the user presses a button:

          this.regionManager.RequestNavigate(

                RegionNames.MainContentRegion,

                ThumbnailsViewUri);

 The new View - ThumbnailsView , a UserControl, is instantiated at this point, but the content control calls function below twice.  The first time, OldContent is equal to the screen with the button, and NewContent is null.  Then OldContent is null and NewContent is equal to the new view above.  Only the animation for the NewContent is done.  The OldContent simply disappears. Doesn't transition like it is supposed to.

         protected override void OnContentChanged(object OldContent, object NewContent)

 Should it be called twice?  Have you done this this way?  I can’t find a  simple example where two views are switched using a transitioningcontentcontrol alone and in Silverlight.

             <TransitioningContentControl 

                x:Name="ItemsControl"

                Canvas.Left="0"

                Custom:RegionManager.RegionName="MainContentRegion"

                Transition="UpTransition"

                />

 Can anyone help?

Jul 1, 2011 at 8:11 PM

Hi,

As this is not strictly related to Prism, you might obtain better support about using TransitioningContentControl control in the Silverlight Forums.

Thanks,

Miguel Bronzovic
http://blogs.southworks.net/mbronzovic

 

Jul 1, 2011 at 9:35 PM

Thanks, but this only appears to occur in this control when used with Prism navigation.  I do have a repro... maybe I am doing something fundamentally wrong...  Not sure where to upload the repro to.

Developer
Jul 4, 2011 at 5:28 PM
Edited Jul 4, 2011 at 6:52 PM

Hi,

You could upload your sample to SkyDrive, or any similar site for sharing files. We'll examine the sample to help you find the cause for that behavior.

Thanks,

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

Nov 8, 2011 at 11:50 AM

 

You have to create a custom RegionAdapter that uses TransitionSingleActiveRegion :

public class TransitioningContentControlRegionAdapter : RegionAdapterBase<TransitioningContentControl >

{

...

        protected override IRegion CreateRegion()        {            return new TransitionSingleActiveRegion();        }

}

public class TransitionSingleActiveRegion : SingleActiveRegion   

{       

public override void Activate(object view)       

{           

...         

object currentActiveView = this.ActiveViews.FirstOrDefault<object>();
            ItemMetadata itemMetadata = Enumerable.FirstOrDefault<ItemMetadata>(this.ItemMetadataCollection, (Func<ItemMetadata, bool>)(x => ((bool)(x.Item == view))));           

if (itemMetadata != null)           

{

 itemMetadata.IsActive = true;             

}           

if (((currentActiveView != null) && (currentActiveView != view)) && this.Views.Contains(currentActiveView))           

{               

base.Deactivate(currentActiveView);           

}
        }   

}