I love Catel framework. Modern UI looks pretty good. But I've faced with problem while trying to make them works together.
I've added two catels usercontrols Home
and Second
in mui project. The problem is that when transition from Home
to Second
performing HomeViewModel
has been created 3 times.
This behavior caused by next code in TransitioningContentControl
private void StartTransition(object oldContent, object newContent)
{
// both presenters must be available, otherwise a transition is useless.
if (CurrentContentPresentationSite != null && PreviousContentPresentationSite != null) {
CurrentContentPresentationSite.Content = newContent;
PreviousContentPresentationSite.Content = oldContent;
// and start a new transition
if (!IsTransitioning || RestartTransitionOnContentChange) {
IsTransitioning = true;
VisualStateManager.GoToState(this, NormalState, false);
VisualStateManager.GoToState(this, Transition, true);
}
}
}
If I comment some lines:
private void StartTransition(object oldContent, object newContent)
{
// both presenters must be available, otherwise a transition is useless.
if (CurrentContentPresentationSite != null && PreviousContentPresentationSite != null) {
CurrentContentPresentationSite.Content = newContent;
//PreviousContentPresentationSite.Content = oldContent;
// and start a new transition
if (!IsTransitioning || RestartTransitionOnContentChange) {
IsTransitioning = true;
//VisualStateManager.GoToState(this, NormalState, false);
//VisualStateManager.GoToState(this, Transition, true);
}
}
}
Same transition in this case results in creating HomeViewModel
1 times, but I dont want creating HomeViewModel
while performing navigation from Home
control. How can I achieve this?