3

I have the following XAML code for a Universal app on Windows Phone 8.1:

<Grid Grid.Row="1">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="2*"/>
        <ColumnDefinition Width="1*"/>
    </Grid.ColumnDefinitions>
    <Image Grid.Column="1" Source="{Binding BarcodeImg}"></Image>
</Grid>

I'm trying to have the image take exactly the middle 50% of the screen, but when I run with this code, the left column gets squeezed. How should I achieve this?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
hxdai
  • 53
  • 1
  • 9
  • that should work. Are there any other elements in your `Grid` that could affect the spacing? Have you tried `Stretch=UniformToFill` on the image? – SWilko Apr 08 '15 at 06:20
  • @dellywheel I have not tried Stretch=UniformToFill. Will give it a try today. thanks. – hxdai Apr 08 '15 at 13:31
  • @dellywheel Stretch=UniformToFill does not work. – hxdai Apr 08 '15 at 23:36

1 Answers1

0
 <Grid Grid.Row="1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*" />
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="1*" />![example pic ][2]
        </Grid.ColumnDefinitions>

        <Image Grid.Column="1"
               HorizontalAlignment="Center"
               VerticalAlignment="Center"
               Source="/Assets/allocate.png"
               Stretch="Uniform" />
    </Grid>
Jayasri
  • 237
  • 1
  • 11
  • Could you elaborate the ![example pic ][2] there? I tried Horizontal/Vertical alignment and that didn't help. – hxdai Apr 08 '15 at 23:37