您的位置:首页 > 其它

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更好用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  wpf