登录窗口布局:[ Grid 布局 -Grid.RowDefinitions / Grid.ColumnDefinitions]

代码如下:

 <Window x:Class="login.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="200" Width="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--默认在第0行0列-->
<!--HorizontalAlignment:水平方向对齐 VerticalAlignment:垂直方向对齐-->
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="username:"></TextBlock>
<TextBox Grid.Column="1" Name="uid" Margin="5"></TextBox>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="password:" Grid.Row="1"></TextBlock>
<PasswordBox Grid.Column="1" Name="pwd" Margin="5" Grid.Row="1"></PasswordBox>
<Button Content="login" Grid.Row="2" Margin="10" Click="Button_Click_1"></Button>
<Button Content="cancer" Grid.Row="2" Margin="10" Grid.Column="1"></Button>
</Grid>
</Window>

Menu / ToolBar 布局:

 <Window x:Class="toolbar.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="打开">
<MenuItem Header="删除"></MenuItem>
</MenuItem>
<MenuItem Header="编辑"></MenuItem>
</Menu>
<ToolBar DockPanel.Dock="Top">
<Button>
<Button.Content>
<Image Source="s.png" Width="16"></Image>
</Button.Content>
</Button> <Button>
<Button.Content>
<Image Source="c.png" Width="16"></Image>
</Button.Content>
</Button>
<CheckBox>
<Image Source="cc.png" Width="16"></Image>
</CheckBox>
</ToolBar>
<TextBox DockPanel.Dock="Bottom"></TextBox>
</DockPanel>
</Grid>
</Window>

如上代码你会发现在为控件设置图标按钮时,会有两种写法  xx.Content  或者直接去除写 <Image...></Image>  ,其实这两个是相同的。

最新文章

  1. Android常用组件之ListView
  2. 学习C++.Primer.Plus 11 使用类
  3. oracle的分析函数over 及开窗函数
  4. HTML5学习之WebSocket通讯(六)
  5. ISODATA算法
  6. android 关于Location of the Android SDK has not been setup in the preferences的解决方法
  7. Swift数字类型之间的转换
  8. 动态规划——C编辑最短距离
  9. shopnc 导出Excel数据问题实例 &amp;&amp; ajax 获取当前值并传递
  10. 那些年搞不懂的&quot;协变&quot;和&quot;逆变&quot;
  11. LeetCode Javascript实现 100. Same Tree 171. Excel Sheet Column Number
  12. 后端开发者的Vue学习之路(一)
  13. linuxmint 搜狗输入法安装
  14. vue项目sql图片动态路径引用问题
  15. library之目录
  16. (转)CS域和PS域
  17. BIO、NIO和AIO的区别(简明版)
  18. 如何使用 MasterPage
  19. playbook-拓展
  20. Android UI-实现底部切换标签(fragment)

热门文章

  1. 不使用CvvImage类来在MFC中显示图像
  2. 华为 2015 机试 输出:数字后面的连续出现的(2个或多个)相同字符(数字或者字符),删去一个,非数字后面的不要删除,例如,对应输出为:33aabb55pin。
  3. POJ-2442 Sequence K路归并问题
  4. mac下firefox复制粘贴失效解决办法
  5. Java用OpenOffice将word转换为PDF
  6. zookeeper-3.4.8 集群搭建
  7. Mac下eclipse安装SVN插件
  8. python module的结构
  9. ThinkPHP3.1新特性:命名范围
  10. js修改input的type属性问题