【问题标题】:Changing base class of a Window更改 Window 的基类
【发布时间】:2015-01-14 02:43:28
【问题描述】:

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

这里有一些代码:

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 位于不同的程序集中。

【问题讨论】:

    标签: c# wpf xaml mvvm


    【解决方案1】:

    我找到了答案。

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

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

    【讨论】:

    • 另外,确保构建。 XAML 将这些标记为错误,直到类被构建。
    猜你喜欢
    • 2014-07-16
    • 1970-01-01
    • 2010-11-22
    • 1970-01-01
    • 1970-01-01
    • 2021-08-30
    • 2015-08-28
    • 1970-01-01
    • 2011-05-19
    相关资源
    最近更新 更多