title: Custom control with TextBox and Button does not inherit styles from parent
body: <p>I created a user control with a TextBox and a Button, but it does not want to use the parent's style. However, my control appeas to have the parent's style at design time, but at runtime the styles disappear.</p>
  
  <p>There is my TextBoxButton.xaml</p>
  
  <pre><code> &lt;Style x:Key="{x:Type Common:TextBoxExtension}" TargetType="{x:Type Common:TextBoxExtension}"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type Common:TextBoxExtension}"&gt;
                  &lt;Border x:Name="border" 
                          Background="{TemplateBinding Background}" 
                          BorderBrush="{TemplateBinding BorderBrush}"
                          BorderThickness="{TemplateBinding BorderThickness}"
                          SnapsToDevicePixels="True"&gt;
                      &lt;DockPanel&gt;
                          &lt;Button DockPanel.Dock="Right" Padding="-3.0" Margin="2"
                                  Width="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type TextBoxBase},Mode=FindAncestor}}"
                                  Content="..."
                                  HorizontalContentAlignment="Center"
                                  VerticalContentAlignment="Center"
                                  Command="{TemplateBinding Command}"/&gt;
                          &lt;ScrollViewer Name="PART_ContentHost" Focusable="False"
                                        HorizontalScrollBarVisibility="Hidden"
                                        VerticalScrollBarVisibility="Hidden"/&gt;
                      &lt;/DockPanel&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Also, there is TextBoxExtension.cs</p>
  
  <pre><code>public class TextBoxExtension : TextBox
  {
      static TextBoxExtension()
      {
          DefaultStyleKeyProperty.OverrideMetadata(typeof(TextBoxExtension), 
              new FrameworkPropertyMetadata(typeof(TextBoxExtension)));
      }
  
      public static readonly DependencyProperty CommandProperty = 
          DependencyProperty.Register("Command", typeof(ICommand), typeof(TextBoxExtension), 
          new PropertyMetadata(null));
  
      public ICommand Command
      {
          get { return (ICommand)GetValue(CommandProperty); }
          set { SetValue(CommandProperty, value); }
      }
  }
  </code></pre>
  
  <p>Usage in window</p>
  
  <pre><code>&lt;Common:TextBoxExtension FontSize="14" Text="{Binding VaultPath, UpdateSourceTrigger=PropertyChanged}" Margin="5" Grid.Column="1" Grid.Row="2" /&gt;
  &lt;Common:TextBoxExtension FontSize="14" Command="{Binding SetLocalPath}" Text="{Binding LocalPath, UpdateSourceTrigger=PropertyChanged}" Margin="5" Grid.Column="1" Grid.Row="3" /&gt;
  </code></pre>
  
  <p>What i expected to get</p>
  
  <p><a href="https://i.stack.imgur.com/wQLjc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wQLjc.png" alt="ExpectedImage"></a></p>
  
  <p>What i get when run the program</p>
  
  <p><a href="https://i.stack.imgur.com/Isx6k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Isx6k.png" alt="RealResults"></a></p>
  
  <p>Want to add that buttons is working</p>