예제 #1
0
        void InitGrid_1()
        {
            //建立StackPanel
            StackPanel stack = new StackPanel();

            stack.Orientation = Orientation.Horizontal;
            this.grid1.Children.Add(stack);

            //建立不做事的按钮,用意是测试输入焦点的转移
            Button btn = new Button();

            btn.Content             = "Do-nothing button \nto test tabbing";
            btn.Margin              = new Thickness(24);
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment   = VerticalAlignment.Center;
            stack.Children.Add(btn);

            //建立ColorGrid控件
            ColorGrid clrgrid = new ColorGrid();

            clrgrid.Margin = new Thickness(24);
            clrgrid.HorizontalAlignment   = HorizontalAlignment.Center;
            clrgrid.VerticalAlignment     = VerticalAlignment.Center;
            clrgrid.SelectedColorChanged += ColorGridOnSelectedColorChanged;
            stack.Children.Add(clrgrid);

            //建立另一个不做事的按钮
            btn                     = new Button();
            btn.Content             = "Do-nothing button \nto test tabbing";
            btn.Margin              = new Thickness(24);
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment   = VerticalAlignment.Center;
            stack.Children.Add(btn);
        }
예제 #2
0
        private void ColorGridOnSelectedColorChanged(object sender, EventArgs e)
        {
            ColorGrid clrgrid = sender as ColorGrid;

            this.grid1.Background = new SolidColorBrush(clrgrid.SelectedColor);
        }