locked
How to arrange images in VariableSizedWrapGrid using x,y Co-ordinates in metro apps using Xaml/C#

    Question

  • Hi,

    I have a List having Image,X Co-ordinates and Y Co-ordinates.

    I want to display images in VariableSizedWrapGrid.I want to position that images with the help of (X,Y) Co-ordinates.

    How to display that images in VariableSizedWrapGrid using X,Y Co-Ordinates in xaml/c# ??

    Kindly reply,its  very Urgent.

    Tuesday, January 13, 2015 11:47 AM

Answers

  • Hi Kachole,

    Per my understanding, you are using the incorrect control. In VariableSizedWrapGrid control, elements are arranged in rows or columns that automatically wrap to a new row or column when they reach the edge of control. You cannot put elements through the co-ordinates. See more information about this control from http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.variablesizedwrapgrid.aspx.

    For your purpose, I would recommend you use Canvas control. You can use co-ordinates to set to Canvas.Left and Canvas.Top properties, this will set the control position in Canvas control. XAML looks like the following.

    <Canvas Background="Black">
    
            <Button Content="Button" Canvas.Left="169" Canvas.Top="60"/>
    
            <Button Content="Button" Canvas.Left="184" Canvas.Top="294"/>
    
            <Button Content="Button" Canvas.Left="169" Canvas.Top="149"/>
    
            <Button Content="Button" Canvas.Left="469" Canvas.Top="230"/>
    
            <Button Content="Button" Canvas.Left="349" Canvas.Top="100"/>
    
    </Canvas>

    You can also set these controls programmatically.

    private void Button_Click(object sender, RoutedEventArgs e)
    
            {
    
                Button btn1 = new Button();
    
                btn1.Content = "Button1";
    
                Canvas.SetLeft(btn1, x);
    
                Canvas.SetTop(btn1, y);
    
                canvas1.Children.Add(btn1);
    
            }

    Please feel free to let me know if you have any concerns.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.


    Wednesday, January 14, 2015 7:02 AM
    Moderator