Chuanzhi podcast-XAML Layout-continuous View Interface (little white content), smart podcast-xaml

Source: Internet
Author: User

Chuanzhi podcast-XAML Layout-continuous View Interface (little white content), smart podcast-xaml

A simple 10*10 link, with 100 grids, you can use ColumnDefinition and RowDefinition to write 10 groups in the XAML, but the efficiency will be very slow. Therefore, it can be dynamically generated.

 

public void FG()        {            Random ran = new Random();            for (int i = 0; i < 10; i++)            {                ColumnDefinition cDef = new ColumnDefinition();                GridGame.ColumnDefinitions.Add(cDef);                RowDefinition rDef = new RowDefinition();                GridGame.RowDefinitions.Add(rDef);            }            for(int i=0;i<10;i++)            {                for(int j=0;j<10;j++)                {                    int ImageName = ran.Next(1, 10);                    Image img = new Image();                    img.Source = new BitmapImage(new Uri("Image/"+ImageName+".png", UriKind.Relative));                    Grid.SetRow(img, i);                    Grid.SetColumn(img, j);                    GridGame.Children.Add(img);                }            }        }

 

The learning content here is the Grid in XAML. row and Grid. column is an additional attribute and cannot be passed in the CS file. to achieve this, you need to use Grid. setRow and Grid. setColumn.

Note: The Next attribute of Random is greater than or equal to the value on the left. <The value on the right, that is, it does not contain the value on the right, or the value on the left.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.