我正在尝试在阅读以下内容后继承UserControl: How can a WPF UserControl inherit a WPF UserControl?
但我似乎错过了一些东西。
基类,它不是部分的,也没有XAML:
namespace HTTPFreeForm
{
public class HTTPBaseForm : UserControl, IForm
/* ... more content ... */
}
子类代码隐藏:
namespace HTTPFreeForm
{
public partial class HTTPFreeForm : HTTPBaseForm
/* ... more content ... */
}
XAML子类:
<local:HTTPBaseForm x:Class="HTTPFreeForm.HTTPFreeForm"
xmlns:local="clr-namespace:HTTPFreeForm"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<!-- ... more content ... -->
</local:HTTPBaseForm>
当我尝试构建时,收到以下错误:
错误2类型名称&#39; HTTPBaseForm&#39;在类型&#39; HTTPFreeForm.HTTPFreeForm&#39;中不存在c:\ MyProject \ HTTPFreeForm \ obj \ Debug \ HTTPFreeForm.g.cs 42 54 HTTPFreeForm
我错过了什么或做错了什么?
答案 0 :(得分:2)
如要求回答的评论。
您的命名空间与类名称相同,名称存在冲突。改变它,然后再试一次。