WPF, XAML: CustomControl like TextBox with caption
<p>My attempt to create a <strong>CustomControl</strong> like a <strong>TextBox</strong> with variable <strong>caption</strong>.</p>

<p>I try to learn create CustomControl and my exceptation is that my CustomControl (I called it <strong>TextBoxCustomControl</strong>) has every properties and methods of TextBox and also has new property <em>Caption</em>.</p>

<p>I hope that is right, that my <strong>TextBoxCustomControl</strong> is inherited from <strong>TextBox</strong> and not from <strong>Control</strong>.</p>

<hr>

<p><strong>TextBoxCustomControl.cs</strong></p>

<pre><code>namespace CustomControlProject
{
    public class TextBoxCustomControl : TextBox
    {
        public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(TextBoxCustomControl), new FrameworkPropertyMetadata(String.Empty));

        public string Caption
        {
            get { return (string)GetValue(CaptionProperty); }
            set { SetValue(CaptionProperty, value); }
        }

        static TextBoxCustomControl()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TextBoxCustomControl), new FrameworkPropertyMetadata(typeof(TextBoxCustomControl)));
        }
    }
}
</code></pre>

<hr>

<p><strong>Themes\Generic.xaml</strong> (specific design for <strong>TextBoxCustomControl</strong>) -- there is the TextBox called <strong>innerTextBox</strong></p>

<pre><code>&lt;ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:CustomControlProject"&gt;


    &lt;Style x:Name="CustomStyle" TargetType="local:TextBoxCustomControl" BasedOn="{StaticResource {x:Type TextBox}}"&gt;
        &lt;Setter Property="Template"&gt;
            &lt;Setter.Value&gt;
                &lt;ControlTemplate TargetType="{x:Type local:TextBoxCustomControl}"&gt;
                    &lt;WrapPanel Orientation="Vertical"&gt;
                        &lt;TextBox x:Name="innerTextBox" /&gt;
                        &lt;Label Content="{TemplateBinding Caption}" /&gt;
                    &lt;/WrapPanel&gt;
                &lt;/ControlTemplate&gt;
            &lt;/Setter.Value&gt;
        &lt;/Setter&gt;
    &lt;/Style&gt;
&lt;/ResourceDictionary&gt;
</code></pre>

<hr>

<p>In <strong>MainWindow.xaml</strong> I use my <strong>TextBoxCustomControl</strong> and specific some properties for it.</p>

<pre><code>&lt;Window x:Class="CustomControlProject.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:CustomControlProject"
        Title="MainWindow" Height="350" Width="525"&gt;
    &lt;WrapPanel&gt;
        &lt;local:TextBoxCustomControl Width="287" Background="Yellow" Caption="Fill the nickname, please." /&gt;
    &lt;/WrapPanel&gt;
&lt;/Window&gt;
</code></pre>

<hr>

<p>My expectation is that innerTextBox inside my TextBoxCustomControl inherit all properties (such like background, width, etc.), but that is not happened. What I do wrong?</p>