title: How to force a usercontrol width to be equal designer width?
body: <p>I have a custom textbox in WPF and I want to change its width while resizing it in designer view. I used <code>Binding</code> <code>ActualHeight</code> but it doesn't work. </p>
  
  <p><a href="https://i.stack.imgur.com/1v2gz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1v2gz.png" alt="enter image description here"></a></p>
  
  <p>As the picture shows I resized the <code>TextBox</code> in design mode but it is still in the same width, not changed. How can I change that control's <code>Width</code>(only) property according to resizing?</p>
  
  <p><strong>DottedTextBox</strong></p>
  
  <pre><code>&lt;UserControl x:Class="Easy_Message.DottedTextBox"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
           mc:Ignorable="d" 
           d:DesignHeight="50" d:DesignWidth="400"&gt;
  &lt;Viewbox&gt;
  &lt;TextBox x:Name="roottxt" Background="White" 
           BorderThickness="0" Width="{Binding ActualWidth,RelativeSource={RelativeSource TemplatedParent}}" Height="20"&gt;
      &lt;TextBox.Template&gt;
          &lt;ControlTemplate TargetType="TextBox"&gt;
              &lt;Grid&gt;
                  &lt;Border x:Name="b" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"
                                 BorderThickness="1,0,1,0" BorderBrush="#c2c4cb"&gt;
                      &lt;Border BorderThickness="0,1,0,0" BorderBrush="#9da0aa"&gt;
                          &lt;Border BorderThickness="0,0,0,1" BorderBrush="#d9dae0"&gt;
                              &lt;DockPanel&gt;
                                  &lt;TextBox x:Name="orgbox" VerticalContentAlignment="Center"
                                       HorizontalAlignment="Left"
                                       BorderThickness="0"
                                       FontSize="{TemplateBinding FontSize}"
                                       Background="White"
                                       Width="{Binding Path=Width,ElementName=b,Converter={StaticResource wconv}}" SelectionBrush="{TemplateBinding SelectionBrush}"
                                       Height="20"&gt;
                                  &lt;/TextBox&gt;
                                  &lt;Border x:Name="brdDot" Background="{TemplateBinding Background}" Grid.Column="1" 
                                      Width="16" Height="{TemplateBinding Height}" HorizontalAlignment="Right"
                                      BorderThickness="0"&gt;
                                      &lt;Canvas HorizontalAlignment="Right"
                                                      Width="10" Height="6" 
                                                      Margin="0,0,2.5,2.5"&gt;
                                          &lt;Rectangle Width="1.5" Height="1.5" Fill="Black"&gt;
                                              &lt;Rectangle.RenderTransform&gt;
                                                  &lt;TranslateTransform X="0" Y="2"/&gt;
                                              &lt;/Rectangle.RenderTransform&gt;
                                          &lt;/Rectangle&gt;
                                          &lt;Rectangle Width="1.5" Height="1.5" Fill="Black"&gt;
                                              &lt;Rectangle.RenderTransform&gt;
                                                  &lt;TranslateTransform X="4" Y="2"/&gt;
                                              &lt;/Rectangle.RenderTransform&gt;
                                          &lt;/Rectangle&gt;
                                          &lt;Rectangle Width="1.5" Height="1.5" Fill="Black"&gt;
                                              &lt;Rectangle.RenderTransform&gt;
                                                  &lt;TranslateTransform X="8" Y="2"/&gt;
                                              &lt;/Rectangle.RenderTransform&gt;
                                          &lt;/Rectangle&gt;
                                      &lt;/Canvas&gt;
                                  &lt;/Border&gt;
                              &lt;/DockPanel&gt;
                          &lt;/Border&gt;
                      &lt;/Border&gt;
                  &lt;/Border&gt;
              &lt;/Grid&gt;
              &lt;ControlTemplate.Triggers&gt;
                  &lt;DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=brdDot}" Value="True"&gt;
                      &lt;Setter TargetName="brdDot" Property="Background"&gt;
                          &lt;Setter.Value&gt;
                              &lt;LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5"&gt;
                                  &lt;GradientStop Color="White" Offset="-0.1"/&gt;
                                  &lt;GradientStop Color="#ccdfff" Offset="0.6" /&gt;
                                  &lt;GradientStop Color="White" Offset="1.1" /&gt;
                              &lt;/LinearGradientBrush&gt;
                          &lt;/Setter.Value&gt;
                      &lt;/Setter&gt;
                      &lt;Setter TargetName="brdDot" Property="BorderThickness" Value="1,0,0,0" /&gt;
                      &lt;Setter TargetName="brdDot" Property="BorderBrush" Value="#ccc9c9"/&gt;
                  &lt;/DataTrigger&gt;
              &lt;/ControlTemplate.Triggers&gt;
          &lt;/ControlTemplate&gt;
      &lt;/TextBox.Template&gt;
  &lt;/TextBox&gt;
  &lt;/Viewbox&gt;
  </code></pre>
  
  <p></p>