Windows 8.1 应用再出发 - 几种常用控件

时间:2014-05-17 19:25:58   收藏:0   阅读:589
原文:Windows 8.1 应用再出发 - 几种常用控件

本篇为大家简单介绍Windows 商店应用中控件的用法,为方便讲解,我们在文本控件和按钮控件这两类中分别挑选有代表性的控件进行详细说明。

1. 文本控件

(1) TextBlock

    TextBlock是最常用的文本显示控件,重点关注以下属性:

bubuko.com,布布扣
        <TextBlock Text="I am a TextBlock ??"
                   CharacterSpacing="100" 
                   HorizontalAlignment="Center" VerticalAlignment="Center" 
                   FontFamily="Arial" FontStyle="Italic" FontSize="50" FontWeight="Black"
                   IsColorFontEnabled="True"
                   LineStackingStrategy="BlockLineHeight"
                   OpticalMarginAlignment="TrimSideBearings"
                   TextAlignment="Center" TextLineBounds="TrimToBaseline" TextReadingOrder="DetectFromContent" 
                   TextTrimming="WordEllipsis" TextWrapping="WrapWholeWords"
                   Height="120" Width="500"/>
bubuko.com,布布扣

 (2) TextBox

     TextBox是文本输入控件,重点关注以下属性:

bubuko.com,布布扣
        <TextBox AcceptsReturn="True" Background="AliceBlue" BorderBrush="Blue" BorderThickness="2" 
                 CompositeMode="Inherit" FlowDirection="RightToLeft" FontFamily="Arial" FontStyle="Italic" FontSize="50" FontWeight="Black" 
                 Header="Header Text" InputScope="Number" IsReadOnly="False" IsSpellCheckEnabled="True" IsTextPredictionEnabled="False" 
                 SelectedText="123" SelectionHighlightColor="AliceBlue" HorizontalAlignment="Center" VerticalAlignment="Center"/>
bubuko.com,布布扣

 (3)PasswordBox

     PasswordBox 是常用的密码输入控件,重点关注以下属性:

        <PasswordBox Height="50" Width="200" MaxLength="8" Password="123456" PasswordChar="*" IsPasswordRevealButtonEnabled="True"/>

 

 2. 按钮控件

(1) Button

    Button是最常用的按钮控件,重点关注以下内容:

bubuko.com,布布扣
        <Button Content="Click Me." ClickMode="Release" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" 
                FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center" Height="200" Width="400" Click="Button_Click">
            <Button.Flyout>
                <Flyout>
                    <TextBlock Text="I am flyout content."/>
                </Flyout>
            </Button.Flyout>
        </Button>
bubuko.com,布布扣

(2) HyperlinkButton 

     HyperlinkButton 是常用的超链接按钮,重点关注以下内容:

        <HyperlinkButton Content="go to google." Foreground="Green" FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center" 
                         HorizontalContentAlignment="Left" VerticalContentAlignment="Top" NavigateUri="http://www.google.com.hk"/>

(3) ToggleButton

    ToggleButton 是可以切换状态的按钮,重点关注以下内容:

        <ToggleButton Content="Toggle Button" IsThreeState="True" FontSize="50" IsChecked="True" HorizontalAlignment="Center" VerticalAlignment="Center" 
                      Checked="ToggleButton_Checked" Unchecked="ToggleButton_Unchecked" Indeterminate="ToggleButton_Indeterminate"/>
bubuko.com,布布扣
        // 按钮变为选中状态后触发的事件
        private void ToggleButton_Checked(object sender, RoutedEventArgs e)
        {}
        // 按钮变为选中未状态后触发的事件
        private void ToggleButton_Unchecked(object sender, RoutedEventArgs e)
        {}
        // 按钮变为不确定状态后触发的事件
        private void ToggleButton_Indeterminate(object sender, RoutedEventArgs e)
        {}
bubuko.com,布布扣

 (4) RadioButton

    RadioButton是单选按钮,继承自ToggleButton,重点关注以下内容:

        <RadioButton GroupName="groupName" IsChecked="True" Content="RadioButton One"/>
        <RadioButton GroupName="groupName" IsChecked="True" Content="RadioButton Two"/>

 (5) CheckBox

    CheckBox是复选按钮,继承自ToggleButton,重点关注以下内容:

        <CheckBox IsChecked="True" Content="CheckBox One"/>
        <CheckBox IsChecked="False" Content="CheckBox One"/>

 

到这里我们就完成了几种常用控件的介绍,希望能帮助大家更好的理解Windows 商店应用中控件的用法,谢谢。

 

Windows 8.1 应用再出发 - 几种常用控件,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!