我正在尝试子类化UserControl后阅读以下内容:WPF UserControl如何继承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类型名称"HTTPBaseForm"不存在于类型"HTTPFreeForm"中。HTTPFreeForm' c:MyProjectHTTPFreeFormobjDebugHTTPFreeForm.g.cs 42 54 HTTPFreeForm
我错过了什么或做错了什么?
按要求评论回答
名称冲突,命名空间与类命名相同。改变一下,再试一次。