gpt4 book ai didi

c# - MyUserControl 不能是 XAML 文件的根,因为它是使用 XAML 定义的

转载 作者:太空狗 更新时间:2023-10-29 17:37:02 31 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Inheriting from a UserControl in WPF

我正在尝试创建一个 WPF 用户控件,它派生自另一个我也已定义的用户控件。

<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">

这是 WelcomeScreen.cs 的样子:

public partial class WelcomeScreen : NavigationControl
{
public WelcomeScreen()
{
this.InitializeComponent();
}
}

编译时出现如下错误:

'myNamespace.NavigationControl' cannot be the root of a XAML file because it was defined using XAML.

我做错了什么?

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com