Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7653363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:00:53+00:00 2026-05-31T12:00:53+00:00

I have an image placed on a Page as follow <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions>

  • 0

I have an image placed on a Page as follow

<Grid x:Name="LayoutRoot" Background="Transparent">
   <Grid.RowDefinitions>
     <RowDefinition Height="Auto"/>
     <RowDefinition Height="*"/>
   </Grid.RowDefinitions>

<Image Name="im" Source="/images/hqdefault.jpg" Height="250" Stretch="UniformToFill"  VerticalAlignment="Center"/>
    </Grid>

this is the whole page XAML, image can be downloaded from http://i.ytimg.com/vi/wNKKCHv-oOw/hqdefault.jpg

Code behind contains some logic to handle the PageOrientation_Change

 private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
 {
    if (Orientation == PageOrientation.Landscape ||
        Orientation == PageOrientation.LandscapeLeft ||
        Orientation == PageOrientation.LandscapeRight)
    {
       im.Height = Application.Current.Host.Content.ActualWidth;
       im.Width = Application.Current.Host.Content.ActualHeight;

       im.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
       im.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
     }
     else
     {
       im.Height = 250;
       im.Width = Application.Current.Host.Content.ActualWidth;
     }
  }

If some one may try this he/she may find that StrechToFill crops the content of the image from bottom where as I am expecting it to crop it from top and bottom equally and keep the image content centered within image control.

HOpe I have made myself clear if not please consider making a sample from provided code. Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:00:55+00:00Added an answer on May 31, 2026 at 12:00 pm

    Main problem was the setting of height or width on the Image control, i am now well aware not to give heigh or width on the image control nor on media element. if you need a a fixed height for example in portrait mode you may put it in a grid control and set its height or width. following is the code which worked for me.

    <Grid Name="grdMedia"
          Grid.Row="1" 
          VerticalAlignment="Stretch" 
          HorizontalAlignment="Stretch"
          Height="250">
    <Image Name="imThumbnail" 
           Grid.Row="1" 
           Stretch="UniformToFill" 
           HorizontalAlignment="Center"
           VerticalAlignment="Center"/>
    </Grid>
    

    And following code if you want to change this picture to full screen in landscape mode

        private void SetUIInLandscape()
        {
            SystemTray.IsVisible = false;
    
           //Do not change the height or width of image control nor its alignments 
           //Hide every thing else
    
            grdMedia.Height = Application.Current.Host.Content.ActualWidth;
            grdMedia.Width = Application.Current.Host.Content.ActualHeight;
    
        }
    
        private void SetUIInPortrait()
        {
            SystemTray.IsVisible = true;
    
            //Do not change the height or width of image control nor its alignments
            //Make every thing else visible
    
            grdMedia.Height = 250;
            grdMedia.Width = Application.Current.Host.Content.ActualWidth;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XAML on my page: <Grid x:Name=LayoutRoot> <Viewbox Stretch=Uniform> <Image x:Name=myImage
I have placed an image on the master page. I see the image at
I have the following image being placed at the top of a page. <body>
There is a map placed as a background image on an html page. There
I have an image which is placed in the middle of the screen all
I have placed an Image as a button in my App and I want
I have a small (100x80) overlay image which will be placed at x=40, y=50
I have image file placed on the one server and application on other server.
I have an image which consists of two arbitrarily placed black 1px blobs on
I have placed an image in one of my mvc 4 aspx application.. now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.