Silverlight 5 で独自のカスタム TextBox コントロールを作成しようとしています。
プロジェクトで再利用できるカスタム ラベル コントロールを既に正常に作成しています。
ラベル コントロールの 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>
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 LabelControl : System.Windows.Controls.Label
{
public LabelControl()
{
InitializeComponent();
}
}
}
ここで、TextBox についても同じことを行いたいと思います。独自のカスタム TextBox コントロールを作成します。TextBox のコードは次のようになります。
<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();
}
}
}
ソリューションの構築中に、次のエラーが発生します。
「タグ 'TextBox' は XML 名前空間 'http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk' に存在しません」
テキスト ボックス コントロールは System.Windows.Controls.TextBox 名前空間にあるように見えるため、XAML で別の名前空間を試しましたが、何も機能しませんでした。
私の質問は:
このカスタム テキスト ボックスを作成するには、どの名前空間を使用する必要がありますか?
名前空間の問題ではない場合、何が欠けていますか?
ありがとうございました。