title: Set Image width and height at runtime
body: <p>I am working on windows phone 8 app.</p>
  
  <p>i have list box with image and value binded to it.I need to set the width and height of the image before its being display.</p>
  
  <p><strong>List Box DataTemplate</strong></p>
  
  <pre><code>   &lt;DataTemplate x:Key="DataTemplate"&gt;
              &lt;Border x:Name="ListItemBorder" 
                      Margin="0,2,0,0" 
                      VerticalAlignment="Stretch"
                      HorizontalAlignment="Stretch"
  
                  &lt;Grid&gt;
                     &lt;Image 
                       Style="{StaticResource ImageStyle}"
                       Stretch="Uniform"
                       Source="{Binding ImageName}"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Margin="1,1,1,1"/&gt;
                 &lt;/Grid&gt;
             &lt;/Border&gt;
     &lt;/DataTemplate&gt;
  </code></pre>
  
  <p><strong>To get the width and height of Image i use this code</strong></p>
  
  <pre><code>int width = 0;
  int height = 0;
  using (var stream = Application.GetResourceStream(new Uri("Assets/test.jpg", UriKind.Relative)).Stream)
  {
      var bmpi = new BitmapImage();
      bmpi.SetSource(stream);
      bmpi.CreateOptions = BitmapCreateOptions.None;
      width = bmpi.PixelWidth;
      height = bmpi.PixelHeight;
      bmpi = null; // Avoids memory leaks
  }
  </code></pre>
  
  <p>But how to change the width and height and set it ?</p>