Windows Store Apps note002 about TextBlock TextBox PasswordBox

1、xaml中输入引号和换行号:

"引号


换行

注意分号必需;


2、TextWrapping属性的不同;


先看看官网中的解释:


例子:

<TextBlock Text="How is it possible? Environmental problem." TextWrapping="NoWrap"  FontSize="40" Height="250" Width="200"/>

<TextBlock Text="How is it possible? Environmental problem." TextWrapping="Wrap"  FontSize="40" Height="250" Width="200"/>

<TextBlock Text="How is it possible? Environmental problem." TextWrapping="WrapWholeWords"  FontSize="40" Height="250" Width="200"/>

NoWrap:无论如何不换行;

Wrap:无论如何都会换行;

WrapWholeWords:换行的时候会保持单词的完整性。


3、TextBlock中的<LineBreak/>用法;

这个在官网讲得挺清楚的:https://msdn.microsoft.com/zh-cn/library/bb979793(v=vs.95).aspx


 

4、TextBlock中字符出界的处理,TextTrimming,参见

https://msdn.microsoft.com/zh-cn/library/windows/apps/windows.ui.xaml.texttrimming.aspx

http://blogs.windows.com/buildingapps/2013/11/11/xaml-text-improvements-in-windows-8-1/


为了更好地说明,改了一下例子:

        <TextBlock TextTrimming="None" Margin="20" TextWrapping="NoWrap" FontSize="30" Width="300" Height="240">
            One<LineBreak/>
            two two<LineBreak/>
            Three Three Three<LineBreak/>
            four four four four<LineBreak/>
            Five Five Five Five Five<LineBreak/>
            six six six six six six<LineBreak/>
            Seven Seven Seven Seven Seven Seven Seven
        </TextBlock>

        <TextBlock TextTrimming="Clip" Margin="20" TextWrapping="NoWrap" FontSize="30" Width="300" Height="240">
            One<LineBreak/>
            two two<LineBreak/>
            Three Three Three<LineBreak/>
            four four four four<LineBreak/>
            Five Five Five Five Five<LineBreak/>
            six six six six six six<LineBreak/>
            Seven Seven Seven Seven Seven Seven Seven
        </TextBlock>

        <TextBlock TextTrimming="CharacterEllipsis" Margin="20" TextWrapping="NoWrap" FontSize="30" Width="300" Height="240">
            One<LineBreak/>
            two two<LineBreak/>
            Three Three Three<LineBreak/>
            four four four four<LineBreak/>
            Five Five Five Five Five<LineBreak/>
            six six six six six six<LineBreak/>
            Seven Seven Seven Seven Seven Seven Seven
        </TextBlock>

        <TextBlock TextTrimming="WordEllipsis" Margin="20" TextWrapping="NoWrap" FontSize="30" Width="300" Height="240">
            One<LineBreak/>
            two two<LineBreak/>
            Three Three Three<LineBreak/>
            four four four four<LineBreak/>
            Five Five Five Five Five<LineBreak/>
            six six six six six six<LineBreak/>
            Seven Seven Seven Seven Seven Seven Seven
        </TextBlock>


5、FlowDirection;

也就是字体从哪边开始出来:

        <TextBlock FontSize="30" Width="300" FlowDirection="RightToLeft" Text="Nigthonke" Margin="533,264,533,470"/>
        <TextBlock FontSize="30" Width="300" FlowDirection="LeftToRight" Text="Nigthonke" Margin="533,318,533,416"/>


6、TextBox;

背景色透明:Background="Transparent"

边框厚度:BorderThickness="10"

从右往左输入:FlowDirection="RightToLeft"

是否检查单词拼写错误,也就是是否在错误单词下面画波浪线:IsSpellCheckEnabled="True"

文字居中显示:TextAlignment="Center"

可输入回车:AcceptsReturn="True"

没有文字时的提醒文字:PlaceholderText="请输入您的用户名"

一些常用的关于TextBox的绑定:

    <Grid Background="Navy">
        <TextBlock HorizontalAlignment="Left" Margin="40,91,0,0" TextWrapping="Wrap" Text="{Binding SelectedText, ElementName=TextBox1}" VerticalAlignment="Top" Height="47" Width="224" FontSize="30"/>
        <TextBlock HorizontalAlignment="Left" Margin="40,178,0,0" TextWrapping="Wrap" Text="{Binding Text, ElementName=TextBox1}" VerticalAlignment="Top" Height="52" Width="224" FontSize="30"/>
        <TextBox x:Name="TextBox1" HorizontalAlignment="Left" Margin="40,254,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="120" Width="224" FontSize="30"/>
        <TextBlock HorizontalAlignment="Left" Margin="296,254,0,0" TextWrapping="Wrap" Text="{Binding Text.Length, ElementName=TextBox1}" VerticalAlignment="Top" Height="71" Width="76" FontSize="30"/>
    </Grid>

效果:


7、PasswordBox;

修改密码的显示字符:PasswordChar="★"

有可见密码按钮:IsPasswordRevealButtonEnabled="True"

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值