更改窗口的基类

本文关键字:基类 窗口 | 更新日期: 2023-09-27 18:37:20

我正在尝试更改已添加到项目中的窗口的基类。

下面是一些代码:

public partial class MoviesView : MvvmHelper.Base.ViewBase
{
    public MoviesView()
    {
        InitializeComponent();
    }
}

和 XAML:

<Mvvm:ViewBase x:Class="MvvmHelperUI.Views.MoviesView"
    xmlns:Mvvm="clr-namespace:MvvmHelper.Base"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MoviesView" Height="300" Width="300">
   <Grid>
   </Grid>
</Mvvm:ViewBase>

我收到错误:

The name "ViewBase" does not exist in the namespace "clr-namespace:MvvmHelper.Base".

还有:

The tag 'ViewBase' does not exist in XML namespace 'clr-namespace:MvvmHelper.Base'.

基类ViewBase目前还没有实现,它只继承自Window。它肯定存在于命名空间中,我不知道这个问题可能是什么。

值得一提的是,ViewBase 位于不同的程序集中。

更改窗口的基类

我找到了答案。

由于 ViewBase 位于不同的程序集中,因此我必须在 XAML 中添加程序集声明:

xmlns:src="clr-namespace:MvvmHelper.Base;assembly=MvvmHelper"