c# - MVVM跨WPF区域实现

标签 c# wpf mvvm view mvvmcross

我如何用MVVM Cross和WPF实现这个 View 呈现;菜单、选项卡和内容 View ?我找不到任何实际的例子如何做到这一点。这是一个过时的实现 https://github.com/ThallisonRhanniel/MvvmCross-Samples/tree/master/XPlatformMenus但我想使用 MvvmCross(6.x) 和 MvvmCross.Platforms.Wpf(6.x)。

主窗口:

[MvxWindowPresentation(Identifier = nameof(MainWindow), Modal = false)]
public partial class MainWindow : MvxWindow<MainWindowViewModel>

菜单:

[MvxContentPresentation(WindowIdentifier = nameof(MainWindow), StackNavigation = true)]
[MvxRegion("MenuContent")]
[MvxViewFor(typeof(MenuViewModel))]
public partial class MenuView

标签栏:

[MvxContentPresentation(WindowIdentifier = nameof(MainWindow), StackNavigation = true)]
[MvxRegion("PageContent")]
[MvxViewFor(typeof(TabViewModel))]
public partial class TabView

使用区域属性;

public class MvxRegionPresentationAttribute : MvxBasePresentationAttribute
{
    public string RegionName { get; set; }
    public string WindowIdentifier { get; set; }
}

MainWindow.xaml 内部;

<Frame x:Name="MenuContent"
       Grid.Column="0"
       NavigationUIVisibility="Hidden"></Frame>

<Frame x:Name="PageContent"
       Grid.Column="1"
       NavigationUIVisibility="Hidden"></Frame>

如何在 MVVMCross 6.x 中实现区域?

最佳答案

搜索所有 mvvmcross wpf github 项目后,我发现了各种实现,但只有一个更新版本; https://github.com/eiadxp/MvvmCross.Platforms.Wpf.ItemsViewPresenter 它使用 MvvmCross(6.x) 和 MvvmCross.Platforms.Wpf(6.x)。

关于c# - MVVM跨WPF区域实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62791660/

相关文章:

wpf - 如何将WPF按钮的内容设置为具有多种颜色?

WPF - 如何通过 MVVM 绑定(bind)控件

c# - 使用 MVVM 在 wpf 中使用对话框的好习惯还是坏习惯?

objective-c - 观察RACSequence中的每一项

c# - 将 EnumMatchToBooleanConverter 添加到我的 xaml 文件时出现问题

c# - Doublebuffer winforms 面板问题

c# - 使用 Twilio(或任何其他提供商)在短信中伪造来电显示

WPF ListView SelectionChanged 内部样式不起作用。 EventSetter 要么

c# - 创建可以绑定(bind)到 DataGrid 的自定义集合

c# - KeyTip 在 Microsoft 功能区中不起作用