MvvmCross WPF-多窗口应用程序(MvxWindow)

时间:2018-09-14 08:22:03

标签: c# wpf xaml mvvmcross multi-window

我已经验证了许多使用MvvmCross框架“如何”创建WPF应用程序的示例。但是没有显示如何创建一个多窗口应用程序。

如何使用自己的ViewModel创建和显示独立窗口?

我的项目文件如下:

MainWindow.xaml => MainWindow.xaml.cs

<div class="main-container">
        <div class="head-banner text-bold new-font">
            <span id="header">WEBSITE PRICE</span>
        </div>
        <div class="body-banner">
            <div class="wrapper">
                <div class="supply">
                    <p><span class="text-bold">1</span> <span class="text-medium">Month Supply</span></p>
                </div>
                <img src="./assets/1md_advtur6_500x500@2x.png" />

                <div class="discount-price">
                    <p class="text-bold">$45.00</p>
                    <p class="between"><span id="strike">$45.00 </span><span>each</span></p>
                </div>
            </div>
        </div>
</div>
        <div class="main-container">
            <div class="head-banner">
                <p class="discount">
                    <span>26</span>
                </p>
                <p class="best">
                    <span>BEST</span><br> <span id="value">VALUE</span>
                </p>
            </div>
            <div class="body-banner">
                <div class="wrapper">
                    <div class="supply">
                        <p><span class="text-bold">6</span> <span class="text-medium">Month Supply</span></p>
                    </div>
                    <img src="./assets/1md_advtur6_500x500@2x.png" />
                    <div class="discount-price">
                        <p class="text-bold">$33.17</p>
                        <p class="between"><span id="strike">$45.00 </span><span>each</span></p>
                    </div>
                </div>
            </div>
    </div>

LoginPageView.xaml => LoginPageView.xaml.cs

public partial class MainWindow : MvxWindow
{
    public MainWindow()
    {
        InitializeComponent();
    }
}

MenuPageView.xaml => MenuPageView.xaml.cs

public partial class LoginPageView : MvxWpfView
{
    public LoginPageView()
    {
        InitializeComponent();
    }
}

当我将MvxWindow类用于MenuPageView时,会出现如下异常。

public partial class MenuPageView : MvxWindow // <-- I want use UserControl (MvxWpfView), and Window (MvxWindow)
{
    public MenuPageView()
    {
        InitializeComponent();
    }
}

0 个答案:

没有答案