zoukankan      html  css  js  c++  java
  • wp7使用C#通过后台动态生成Grid网格布局

    一、创建相关对象,并定义Grid中的列属性

    Grid forwardAndReply = new Grid();//创建Grid对象

     forwardAndReply.Margin = new Thickness(0, 10, 0, 5);
     forwardAndReply.HorizontalAlignment = HorizontalAlignment.Right;
     forwardAndReply.Height = 30;


    //创建第一个ColumnDefinition
     ColumnDefinition firstColumnDefinition = new ColumnDefinition();//定义Grid列属性对象
     firstColumnDefinition.Width = new GridLength(125, GridUnitType.Pixel);//初始化GridLength并设置指定的值
     forwardAndReply.ColumnDefinitions.Add(firstColumnDefinition);//添加ColumnDefinition到Grid的列属性集合中


    //创建第二个ColumnDefinition
    ColumnDefinition secondColumnDefinition = new ColumnDefinition();
    secondColumnDefinition.Width = new GridLength(125, GridUnitType.Pixel);
    forwardAndReply.ColumnDefinitions.Add(secondColumnDefinition);

    二、将UI元素添加到指定的列中

    RichTextBox content = new RichTextBox();//创建RichTextBox控件对象
    Grid.SetColumn(forward,0);//设置即将要添加的UI元素所在的列,0为第一列
    forwardAndReply.Children.Add(forward);//添加UI元素到Grid中

  • 相关阅读:
    Word Search
    Subsets
    Combinations
    Search a 2D Matrix
    求比正整数N大的最小正整数M,且M与N的二进制表示中有相同数目的1
    Set Matrix Zeroes
    Unity学习笔记—— 常用脚本函数
    学习 各个数据结构
    unity调用 安卓相册
    设置 相机跟随 主角及视角 滑动
  • 原文地址:https://www.cnblogs.com/xiaofoyuan/p/2582421.html
Copyright © 2011-2022 走看看