在WPF應用程序(VB.net)中,我試圖創建一個基本用戶控件,其中2個其他用戶控件從中繼承。如何爲多個用戶控件實現超類
這是我到現在爲止:
我的基類:
PUblic MustInherit Class BaseUserControl
Inherits UserControl
Implements INotifyPropertyChanged
'common properties
'common methods
End Class
我繼承的用戶控件,.xaml.vb文件:
PUblic Class myUserControlOne
Inherits BaseUserControl
Public Sub New()
InitializeComponent()
End Sub
End Class
我繼承的使用控件,.xaml文件:
<local:BaseUserControl x:Class="myUserControlOne"
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:TestProject"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<Grid>
</Grid>
</local:BaseUserControl>
我看到幾篇文章和問題上堆棧溢出,像this,this,this,this等。但是,我仍然得到一個錯誤,我沒有得到我的地方錯誤的根源。
這是我目前的錯誤:命名空間「clr-namespace:TestProject」中不存在名稱「BaseUserControl」。
我對WPF和VB.net比較陌生,我很感激任何幫助。
是在WPF應用程序項目中定義的BaseUserControl類還是您有幾個不同的項目?另外,什麼是 local:ucCoreDiagram>? – mm8
一切都在一個單一的項目。這是一個錯誤的問題,感謝您指出它;) – Yvonnila
而且你不能建立該項目? – mm8