Search code examples
gridviewwindows-phone-8windows-phone-8.1gmgridviewcell

Image not fitting in grid view cell in windows phone 8


enter image description herei want to append the image url to image controller in grid view . but image is not properly fitted to grid view cell. so please any one help me to how to do this.

MY CODE:

<GridView x:Name="listviewfreecredits" Margin="0,-1,0.643,10" Height="521" IsItemClickEnabled="True" ItemClick="listviewfreecredits_ItemClick"  >
                        <GridView.ItemTemplate>
                            <DataTemplate>
                                <Grid  Margin="10,0,0,0"  >
                                    <Border  BorderBrush="Black" BorderThickness="2" Margin="0,5,0,5">

                  [![enter image description here][1]][1]

                                        <Image Source="{Binding DealImage}" Stretch="None" Width="180" Height="245" Margin="0,5,0,5" />
                                    </Border>
                                    <TextBlock Text="{Binding DealID}" Visibility="Collapsed"></TextBlock>


                                </Grid>
                            </DataTemplate>
                        </GridView.ItemTemplate>

                    </GridView>

codeview:

 JObject jobj = JObject.Parse(result);
                JArray jarr = (JArray)jobj["Deals"];
                if (jarr != null)
                {
                    for (int i = 0; i < jarr.Count; i++)
                    {
                        string DealImage = (string)jarr[i]["DealImage"];

                        freecredit obj = new freecredit();
                        obj.DealImage = Url.imgurl + DealImage;

                        this.listviewfreecredits.Items.Add(obj);

                    }
                }

in the above screenshot in girdview cell image is not properly fitted.(image was cutting).how to minimize image.please help me.

EDIT:

finally I got a solution.Just I removed Strech=none" and replaced with Stretch="Uniform".


Solution

  • Just remove Stretch="None" or replace it with Stretch="UniformToFill" on the Image depending on how you want it cropped.