PRISM WPF 和 MaterialDesignInXaml 转换工具

PRISM WPF and MaterialDesignInXaml transitioner

我正在尝试使用 Transitioner from MaterialDesignInXaml with a PRISM 7 WPF app as a region to get animation on navigation. The two "work" together in the sense that navigation of views is succcessful but only the first view animates. After poking around I created my own RegionAdapter with a new RegionBehavior that I copied from PRISM 来玩。

我的想法是,同步事件处理程序可能在过渡器有机会制作其启用其动画的容器之前触发。我注意到的可疑行为是,当 this line executed 时,它会清除 Transitioner 的 SelectedItem 并且动画不会触发。 (这是上周五的一天结束,所以很抱歉周一早上有点模糊。)

所以我添加了一个真正复杂的机制,允许过渡到 "catch up" (await Task.Delay(1)) 在 equivalent of this line 并且动画开始工作。现在它不会在视图停用时清除 SelectedItem。

我的问题是为什么以及如何更优雅地做到这一点?我对自定义 WPF UI 控件没有太多经验。我真的不喜欢我所拥有的,它基本上是一个分叉的 SelectorRegionAdapter,带有等待发生的竞争条件。

我最终深入研究了 MaterialDesignInXaml 代码库,发现除非加载视图,否则 Transitioner 不会触发动画。所以我最终用 FrameworkElement.Loaded 事件的事件处理程序替换了我的 Task.Delay(1)

所以我最终使用了库的 SelectorRegionAdapter 的 90%,除了它 select 我监听 Loaded 的新活动视图,然后一旦发生我 select 新视图。