0

I'm new on Windows development and more in Windows Phone Development.

I'm trying to create a grid view composed of three cell. Each grid view are composed of one image (for the background) and a textblock.

My background image is a cloud image and I want the first image partialy hidden by the second one and the second one partially hidden by the third one.

I tried to play with the margin of the cell for the y part, that's works but my cloud image doesn't make the entire width of my cell. So I tried the "UnifirmToFill" option but my images are cropped...

On iOS development in this case we can use the magic property "ClipToBounds", everywhere I saw the answer "use the clip to bounds property" but apparently this property is a legend or Visual Studio lie me...

Do you have an idea to resolve my problem ?

Thank you in advance!

To resume: If I use the "uniformToFill" stretch option, my image is zoomed. It is ok for me.

But there is a way to display the cropped part? I want my image zoomed and displayed out the cell view.

Atlandu
  • 29
  • 5

1 Answers1

0

In XAML there are four possible Stretch options:

None
The image is shown in it's original size. If its larger than the parent element, it'll only show the top left portion of the image that fits inside. If the image is smaller than the parent element, then it's shown in it's entirety.

Fill
The image is resized to fill the parent element. If the aspect ratios are different, then the image will be stretched to fit the parent. This will distort the image.

Uniform
The image will be scaled up as large as it can be, while still being completely inside of the parent. Unlike Fill which will stretch the image to make it fit perfectly, Uniform will keep the aspect ratio of the image and stop scaling when it reaches the bounds of the parent.

UniformToFill This is the bastard child of the previous two. It will scale the image, while keeping the aspect ratio, until it fills the parent element. This means that some parts of the image will be clipped if the aspect ratios are different.

For more information on the Stretch enumeration, hit it up on MSDN

UPDATE
If you want to show the image outside of the bounds of the parent you could do something like this:

<Grid Width="100" Height="50">
    <Grid.Clip>
        <RectangleGeometry Rect="0 0 100 50"/>
    </Grid.Clip>
</Grid>

This was suggested here on SO

Community
  • 1
  • 1
Jon G Stødle
  • 3,844
  • 1
  • 16
  • 22
  • Thank you, maybe I didn't correctly explain my problem... I edited my question by adding (I hope) a clearly description of my problem. – Atlandu Jul 16 '15 at 06:37