zoukankan      html  css  js  c++  java
  • Windows phone7 动态添加控件

    Windows phone7 动态添加控件
    2011-03-29 3:48

    using System;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Microsoft.Phone.Controls;


    namespace testbywgscd
    {
        public partial class MainPage : PhoneApplicationPage
        {
            // Constructor
            public MainPage()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, RoutedEventArgs e)
            {

                for (int i = 0; i < 5; i++)
                {

                    var checkbox = new CheckBox
                    {

                        Content = "inbox",

                        HorizontalAlignment = HorizontalAlignment.Left,

                        VerticalAlignment = VerticalAlignment.Top,

                        FontFamily = new FontFamily("Calibri"),
                        FontSize = 30,
                        Margin= new Thickness(11,i*101,0,0),
                        Width=101,
                        Height=101,
            

                    };

                checkbox.Checked +=new RoutedEventHandler(checkbox_Checked);
                ContentPanel.Children.Add(checkbox); //ContentPanel is  grid control
              //  FrameworkDispatcher.Update();

                    //  Grid.SetRow(checkbox, i + 10);
                    // Grid.SetRow(checkbox, i + 10);

                }

            }

            void checkbox_Checked(object o, RoutedEventArgs e) {

                MessageBox.Show("hello6");
          
           
            }


        }
    }

  • 相关阅读:
    Solon 特性简集,相较于 Springboot 有什么区别?
    Solon 1.2.12 发布,新的惊喜
    Springboot mini
    Springboot mini
    Springboot mini
    Springboot mini
    Springboot mini
    Springboot mini
    Springboot mini
    CODING 静态网站服务升级,快速、稳定、高拓展!
  • 原文地址:https://www.cnblogs.com/songtzu/p/2434531.html
Copyright © 2011-2022 走看看