wpf快速学习笔记一 xaml基础知识
2013-01-30 12:02
453 查看
1、xaml 基础知识 :xaml其实就是xml结构的脚本语言,与flex中的标签语言极其相识。
主要用于Silverlight,WPF,Windows Phone以及Windows 8应用开发。
2、xaml语法 :
1)命名空间声明
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2) 标签
.布局标签: Canvas(画布)、StackPanel(排列容器)与 Grid(表格)
Canvas :画布 就像一张白纸一样想画什么就画什么。
StackPanel:是一个有规则排列的控件容器,在该里面的控件都会自动垂直或者水平有规律
的排列(如图按钮垂直排列)。
源码:
<Window x:Class="firstApplicaton.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<StackPanel>
<Button x:Name="button1" Content="按钮1" Width="80"/>
<Button x:Name="button2" Content="按钮2" Width="80" Height="21" />
</StackPanel>
</Window>
Grid :表格 整个界面就是一个表格的样式(图两行两列的表格)
源码:
<Window x:Class="firstApplicaton.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="120"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button x:Name="button1" Content="按钮1" Width="80" Height="20"
Grid.Column="0" Grid.Row="0"/>
<Button x:Name="button2" Content="按钮2" Width="80" Height="20"
Grid.Column="1" Grid.Row="1" />
</Grid>
</Window>
.常用标签 button 、label 、textBox 等等。
总体来说 xaml 跟html相似 但是比 html更好用。
主要用于Silverlight,WPF,Windows Phone以及Windows 8应用开发。
2、xaml语法 :
1)命名空间声明
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2) 标签
.布局标签: Canvas(画布)、StackPanel(排列容器)与 Grid(表格)
Canvas :画布 就像一张白纸一样想画什么就画什么。
StackPanel:是一个有规则排列的控件容器,在该里面的控件都会自动垂直或者水平有规律
的排列(如图按钮垂直排列)。
源码:
<Window x:Class="firstApplicaton.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<StackPanel>
<Button x:Name="button1" Content="按钮1" Width="80"/>
<Button x:Name="button2" Content="按钮2" Width="80" Height="21" />
</StackPanel>
</Window>
Grid :表格 整个界面就是一个表格的样式(图两行两列的表格)
源码:
<Window x:Class="firstApplicaton.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="120"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button x:Name="button1" Content="按钮1" Width="80" Height="20"
Grid.Column="0" Grid.Row="0"/>
<Button x:Name="button2" Content="按钮2" Width="80" Height="20"
Grid.Column="1" Grid.Row="1" />
</Grid>
</Window>
.常用标签 button 、label 、textBox 等等。
总体来说 xaml 跟html相似 但是比 html更好用。
相关文章推荐
- WPF基础知识学习笔记(一)XAML基础
- wpf基础快速学习 一 xaml 基础知识学习
- PHP学习笔记1:基础知识快速浏览
- WPF基础知识学习笔记——序
- PHP学习笔记1:基础知识快速浏览
- Angular 4 学习笔记 从入门到实战 打造在线竞拍网站 基础知识 快速入门 个人感悟
- Servlet&JSP学习笔记:Web应用程序基础知识
- CSS基础知识学习笔记
- C/C++学习笔记:基础知识8
- 【2018.04.09学习笔记】【linux基础知识4.1-4.4、扩展学习parted分区gpt格式】
- Java学习笔记-《Java程序员面试宝典》-第四章基础知识-4.4基本类型与运算(4.4.5-4.4.10)
- libevent学习笔记 一、基础知识
- 黑马学习笔记_java基础知识总结
- C#学习笔记(八)—–LINQ查询的基础知识(中)
- Java学习笔记-《Java程序员面试宝典》-第四章基础知识-4.2面向对象技术(4.2.10-4.2.11)
- PHP学习笔记(一)基础知识
- Deep Learning 深度学习笔记1(基础知识)
- 前端学习笔记--jQuery--基础知识--样式篇
- Android Map开发基础知识学习笔记
- Oracle11g基础知识【SQL学习笔记】