我正在尝试按照如何让WPF用户控件继承另一个WPF用户控件中提到的方法来继承WPF中的用户控件。
namespace DMS.Presentation
{
/// <summary>
/// Interaction logic for WorkSpaceViewControl
/// </summary>
public abstract class WorkSpaceViewControl : UserControl
{
public WorkSpaceViewControl()
{
InitializeComponent();
}
private void InitializeComponent()
{
}
}
}
目前为止代码没有给出任何错误。但是当我在一个新的用户控件中继承它时:
namespace DMS.Presentation
{
/// <summary>
/// Interaction logic for AnimalWorkSpaceView.xaml
/// </summary>
public partial class AnimalWorkSpaceView : WorkSpaceViewControl
{
public AnimalWorkSpaceView()
{
InitializeComponent();
}
}
}
它的XAML文件如下:
//I have tried both WorkSpaceViewControl:UserControl and UserControl:WorkSpaceViewControl here
<UserControl:WorkSpaceViewControl x:Class="DMS.Presentation.WorkSpaceViewControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DMS.Presentation"
xmlns:WorkSpaceViewControl="clr-namespace:DMS.Presentation"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
</UserControl:WorkSpaceViewControl>
我收到了一个消息,说部分修饰符不存在。另一个 WorkSpaceViewControl 的部分声明已经存在。那么我应该如何实现它,问题出在哪里?由于这个继承瓶颈,我的整个项目都卡住了,自从一月份以来。真的需要帮助。