In my previous post, BuildIt.States from a ViewModel, I showed a rather messy way to connect on StateManager to another. I’m just in the process of refactoring BuildIt.States to include an extra method on the IStateManager interface to enable simple binding between two StateManagers, and their respective StateGroups. This would significantly simplify the code necessary, as well as ensuring all StateGroups within the two StateManagers are synchronized.
private IStateBinder Binder { get; set; }
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Binder = manager.Bind(ViewModel.StateManager);
}
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
base.OnNavigatingFrom(e);
Binder?.Unbind();
Binder = null;
}
I’ll be updating the BuildIt.States NuGet package in the coming days to include this additional method.