<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>
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>
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) { } } }