title: Prevent resize of control in grid WPF C#
body: <p><strong>(Edit)</strong> i have an image in tabItem1. when i resize window(dragging by corner or maximize button) the image also resize and occupy whole grid. i added width and height on image and the resisng stopped default to actual image width &amp; height in pixels.</p>
  
  <p>Do i have to apply width and height to prevent resising of control whom i don't want to resize on window scale? or is there any property for controls to prevent resizing.</p>
  
  <p>Basically, i'll have some pics which i don't want to be resided, and there will be some text which i want to be resided.</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="Engine.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Width="600" Height="600"&gt;
      &lt;Grid&gt;
          &lt;TabControl Grid.RowSpan="2"&gt;
              &lt;TabItem Header="TabItem1"&gt;
                  &lt;ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"&gt;
                      &lt;Grid x:Name="TGrid1" Background="#FFE5E5E5"/&gt;
                  &lt;/ScrollViewer&gt;
              &lt;/TabItem&gt;
              &lt;TabItem Header="TabItem2"&gt;
                  &lt;ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"&gt;
                      &lt;Grid x:Name="TGrid2" Background="#FFE5E5E5"&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition/&gt;
                              &lt;RowDefinition/&gt;
                          &lt;/Grid.RowDefinitions&gt;
                      &lt;/Grid&gt;
                  &lt;/ScrollViewer&gt;
              &lt;/TabItem&gt;
          &lt;/TabControl&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>public MainWindow()
  {
          InitializeComponent();
  
          var bitmapFrame = BitmapFrame.Create(new Uri(@"" + AppDomain.CurrentDomain.BaseDirectory + "Chrysanthemum.jpg"), BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);
          var dragDropImage = new Image
          {
              Source = bitmapFrame, //new BitmapImage(new Uri(@"" + AppDomain.CurrentDomain.BaseDirectory + "Chrysanthemum.jpg")),
              Name = "dragDropImage",
              Width = bitmapFrame.PixelWidth,
              Height = bitmapFrame.PixelHeight
          };
          TGrid1.Children.Add(dragDropImage);
  
          var rect = new Rectangle
          {
              Stroke = new SolidColorBrush(Colors.Red),
              Fill = new SolidColorBrush(Colors.Black),
              Width = 474,
              Height = 405
          };
          Grid.SetRow(rect, 0);
          TGrid2.Children.Add(rect);
    }
  </code></pre>