• WPF之DockPanel 、 StackPanel


    <Window x:Class="WPFdemo1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="327" Width="729">
        <DockPanel Name="dockPanel1" LastChildFill="False">
            <Button Name="button1" DockPanel.Dock="Top">1</Button>
            <Button Name="button2" DockPanel.Dock="Bottom" >2</Button>
            <Button Name="button3" DockPanel.Dock="Left">3</Button>
            <Button Name="button4" DockPanel.Dock="Right">4</Button>
            <Button DockPanel.Dock="Top">剩余空间</Button>
        </DockPanel>
    </Window>

    <Window x:Class="WPFdemo1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="简单对话框实例" Height="327" Width="729">
        <DockPanel Name="dockPanel1">
            <StackPanel Name="stackPanel1" Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Right">
                <Button Name="button1" Margin="10,10,2,10" Padding="3">确定</Button>
                <Button Name="button2" Margin="2,10,10,10" Padding="3">返回</Button>
            </StackPanel>
            <TextBlock Name="textBlock1" Text="简单对话框实例,按请单击确定返回" Margin="10" />
        </DockPanel>
    </Window>

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;

    namespace WPFdemo1
    {
        /// <summary>
        /// Window3.xaml 的交互逻辑
        /// </summary>
        public partial class Window3 : Window
        {
            public Window3()
            {
                InitializeComponent();
                this.Content = CreateGrid();
            }

            public Grid CreateGrid()
            {
                Grid grd = new Grid();
                RowDefinition row1 = new RowDefinition();
                row1.Height = new GridLength(1, GridUnitType.Star);
                grd.RowDefinitions.Add(row1);
                RowDefinition row2 = new RowDefinition();
                row2.Height = GridLength.Auto;
                grd.RowDefinitions.Add(row2);
                TextBox txt = new TextBox();
                txt.Text = "c测试";
                txt.TextWrapping = TextWrapping.Wrap;
                Grid.SetRow(txt, 0);
                Grid.SetColumn(txt, 0);
                grd.Children.Add(txt);

                StackPanel stk = new StackPanel();
                stk.Orientation = Orientation.Horizontal;
                stk.HorizontalAlignment = HorizontalAlignment.Right;
                Grid.SetColumn(stk, 0);
                Grid.SetRow(stk, 1);
                grd.Children.Add(stk);


                Button btn = new Button();
                btn.Margin = new Thickness(10, 10, 2, 10);
                btn.Content = "确定";
                btn.Padding = new Thickness(3);
                stk.Children.Add(btn);

                Button btn1 = new Button();
                btn1.Margin = new Thickness(2, 10, 10, 10);
                btn1.Content = "取消";
                btn1.Padding = new Thickness(3);
                stk.Children.Add(btn1);
                return grd;


            }

            private void Window_Loaded(object sender, RoutedEventArgs e)
            {

            }
        }
    }

  • 相关阅读:
    setTimeout的时间设为0的问题
    nodejs的简单服务器程序
    使用Promise规定来处理ajax请求的结果
    使用myfocus制作焦点图
    给Array添加删除重复元素函数
    css派生选择器
    Javascript 参数传递
    Node.js 搞Javascript开发的无论如何要尝试一下
    CSS九宫格带边框的多种实现
    80%人会答错的JS基础面试题
  • 原文地址:https://www.cnblogs.com/zhangtao/p/2347597.html
Copyright © 2020-2023  润新知