Prism RegionAdapter on SfNavigationDrawer

129 views Asked by At

I'm trying to implement a RegionAdapter on the Syncfusion navigation drawer (https://help.syncfusion.com/wpf/navigation-drawer/getting-started).

I saw that it uses a variable (object) ContentView for displaying view so I wrote this :

public class SfNavigationDrawerRegionAdapter : RegionAdapterBase<SfNavigationDrawer>
{
    public SfNavigationDrawerRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) : base(regionBehaviorFactory)
    {
    }

    protected override void Adapt(IRegion region, SfNavigationDrawer regionTarget)
    {
        if (region == null)
        {
            throw new ArgumentNullException(nameof(region));
        }

        if (regionTarget == null)
        {
            throw new ArgumentNullException(nameof(regionTarget));
        }

        region.Views.CollectionChanged += (s, e) =>
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (FrameworkElement view in e.NewItems) { 
                    regionTarget.ContentView = view;
                }
            } 
            // in events Remove is never called but Reset is called after a Add action
        };
    }

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

This snippet does the following behavior : (https://i.imgur.com/kHVFfQh.mp4) when I click back on a View already loaded it doesn't change the View in the ContentView (not calling the CollectionChanged).

The expected behavior is that it should display the View.

How can I manage to do that?

Thank you for reading!

0

There are 0 answers