Possible Duplicate:
Inheriting from a UserControl in WPFMyUserControl không thể là gốc rễ của một file XAML bởi vì nó được định nghĩa sử dụng XAML
Tôi đang cố gắng để tạo ra một điều khiển người dùng WPF, được bắt nguồn từ một điều khiển người dùng khác, mà tôi cũng đã xác định.
<myNamespace:NavigationControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:myNamespace="clr-namespace:myNamespace" mc:Ignorable="d"
x:Class="myNamespace.WelcomeScreen"
x:Name="UserControl"
d:DesignWidth="640" d:DesignHeight="480">
và đây là những gì WelcomeScreen.cs trông giống như: lỗi
public partial class WelcomeScreen : NavigationControl
{
public WelcomeScreen()
{
this.InitializeComponent();
}
}
Khi tôi biên dịch này, tôi nhận được như sau:
'myNamespace.NavigationControl' cannot be the root of a XAML file because it was defined using XAML.
Tôi đang làm gì sai?
cho cách giải quyết WPF với kế thừa Visual xem: http://svetoslavsavov.blogspot.gr/2009/09/user-control-inheritance-in-wpf.html hoặc để xác định rõ ràng GUI trong tổ tiên xem http: // support.microsoft.com/kb/957231 –