C# Silverlight 5.0自定义文本框:标签;文本框“;命名空间中不存在

C# Silverlight 5.0自定义文本框:标签;文本框“;命名空间中不存在,c#,silverlight,textbox,custom-controls,label,C#,Silverlight,Textbox,Custom Controls,Label,我正在尝试用Silverlight 5编写自己的自定义文本框控件 我已经成功地编写了一个自定义标签控件,我可以在我的项目中重用它 标签控件的XAML和代码如下所示 以下代码对我有效: <sdk:Label x:Class="Gui.CustomControls.LabelControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.

我正在尝试用Silverlight 5编写自己的自定义文本框控件

我已经成功地编写了一个自定义标签控件,我可以在我的项目中重用它

标签控件的XAML和代码如下所示

以下代码对我有效:

<sdk:Label 

x:Class="Gui.CustomControls.LabelControl"
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:sw="clr-namespace:System.Windows;assembly=System.Windows"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="125">

<Grid x:Name="LayoutRoot" Background="White">

</Grid>
现在我想对文本框做同样的事情——编写自己的自定义文本框控件。 文本框的代码如下所示:正如您可能看到的,它几乎是一样的

<sdk:TextBox 

    x:Class="Gui.CustomControls.TextBoxControl"
    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:sw="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    mc:Ignorable="d"
    d:DesignHeight="25" d:DesignWidth="125">

    <Grid x:Name="LayoutRoot" Background="White">

    </Grid>
</sdk:TextBox>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Gui.CustomControls
{
    public partial class TextBoxControl : System.Windows.Controls.TextBox
    {
        public TextBoxControl()
        {
            InitializeComponent();

        }



    }
}

使用制度;
使用System.Collections.Generic;
使用System.Linq;
Net系统;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Animation;
使用System.Windows.Shapes;
命名空间Gui.CustomControls
{
公共部分类TextBoxControl:System.Windows.Controls.TextBox
{
公共TextBoxControl()
{
初始化组件();
}
}
}
构建解决方案时发生以下错误:

“XML命名空间中不存在标记“TextBox”http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk""

由于textbox控件似乎位于System.Windows.Controls.textbox名称空间中,我在XAML中尝试了不同的名称空间,但没有任何效果

我的问题是:

要构建此自定义文本框,我必须使用哪个命名空间

如果不是名称空间问题,那么我缺少什么


谢谢。

它不是
sdk:TextBox
,只是
TextBox
(即
http://schemas.microsoft.com/winfx/2006/xaml/presentation
,这是大多数XAML文件中的默认XMLN)。奇怪的是,它没有记录在类中,但却记录在类中。

它不是
sdk:TextBox
,只是
TextBox
(即
http://schemas.microsoft.com/winfx/2006/xaml/presentation
,这是大多数XAML文件中的默认XMLN)。奇怪的是,这并没有记录在课堂上,但却记录在课堂上。

谢谢。我可以看到就在那里。伙计,小问题-2小时后。谢谢。我可以看到就在那里。伙计,小问题-2小时后。
<sdk:TextBox 

    x:Class="Gui.CustomControls.TextBoxControl"
    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:sw="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    mc:Ignorable="d"
    d:DesignHeight="25" d:DesignWidth="125">

    <Grid x:Name="LayoutRoot" Background="White">

    </Grid>
</sdk:TextBox>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Gui.CustomControls
{
    public partial class TextBoxControl : System.Windows.Controls.TextBox
    {
        public TextBoxControl()
        {
            InitializeComponent();

        }



    }
}