一、TextBox

TextBox 显示和编辑单格式、多行文本的控件

将TextWrapping的特性设置为Wrap会使文本在到达TextBox控件的边缘时换至新行。必要时会自动扩展TextBox以便为新行留出空间

将AcceptReturn特性设置为true会导致在按换行键时插入新行,必要时会再次自动扩展TextBox以便为新行留出空间。

文本框的大小固定时,内容过多就需要添加滚动条来显示全部的内容了。

设置 HorizontalScrollBarVisibility 属性用以启动水平滚动条

设置 VerticalScrollBarVisibility 属性用以启动垂直滚动条

<phone:PhoneApplicationPage.Resources>
        <ResourceDictionary>
            <!--设置TextBox的样式-->
            <Style x:Key="TextBoxStyle1" TargetType="TextBox">
                <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
                <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
                <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
                <Setter Property="Foreground" Value="Blue"/>
                <Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}"/>
                <Setter Property="SelectionBackground" Value="{StaticResource PhoneAccentBrush}"/>
                <Setter Property="SelectionForeground" Value="{StaticResource PhoneTextBoxSelectionForegroundBrush}"/>
                <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
                <Setter Property="Padding" Value="2"/>
            </Style>
        </ResourceDictionary>
    </phone:PhoneApplicationPage.Resources>
<!--创建一个自动折行并使用上面定义的TextBoxStyle1样式资源的控件-->
            <TextBox Style="{StaticResource TextBoxStyle1}" Margin="12,31,22,473" Name="TextBox1" TextWrapping="Wrap"   HorizontalScrollBarVisibility="Disabled" AcceptsReturn ="true"  TextChanged="TextBox1_TextChanged"/>
            <TextBlock Height="60" HorizontalAlignment="Left" Margin="12,221,0,0" Name="textBlock1" Text="" VerticalAlignment="Top" Width="364" />
            <TextBlock Height="43" HorizontalAlignment="Left" Margin="12,172,0,0" Name="textBlock2" Text="获取TextBox的输入:" VerticalAlignment="Top" Width="170" />

二、TextBlock

<!--创建一个简单的TextBlock控件-->
            <TextBlock x:Name="TextBlock2" Height="30" Text="你好,我是TextBlock控件" Foreground="Red" Margin="25,84,177,493">
            </TextBlock>
            <!--给同一个TextBlock控件的文字内容设置多种不同的样式-->
            <TextBlock Margin="25,171,19,384">
            <TextBlock.Inlines>
                <Run  FontWeight="Bold" FontSize="14" Text="TextBlock. " />
                <Run FontStyle="Italic" Foreground="Red" Text="red text. " />
                <Run FontStyle="Italic" FontSize="18" Text="linear gradient text. ">
                    <Run.Foreground>
                        <LinearGradientBrush>
                            <GradientStop Color="Green" Offset="0.0" />
                            <GradientStop Color="Purple" Offset="0.25" />
                            <GradientStop Color="Orange" Offset="0.5" />
                            <GradientStop Color="Blue" Offset="0.75" />
                        </LinearGradientBrush>
                    </Run.Foreground>
                </Run>
                <Run FontStyle="Italic" Foreground="Green" Text=" green " />
            </TextBlock.Inlines>
          </TextBlock>
            <!--自定义断行-->
            <TextBlock Margin="9,344,230,130">
            你好!
            <LineBreak/>
            我是TextBlock
            <LineBreak/>
            再见
            <LineBreak/>
            --2011年6月8日
            </TextBlock>
            <!--设置TextBlock自动折行-->
            <TextBlock TextWrapping="Wrap" Margin="279,344,19,154">
    好像内容太长长长长长长长长长长长长长长长长长长了
            </TextBlock>
            <!--不设置自动折行-->
            <TextBlock  Margin="248,477,50,77">
    好像内容太长长长长长长长长长长长长长长长长长长了
            </TextBlock>
            <!--设置TextBlock控件内容的颜色渐变-->
            <TextBlock Text="颜色变变变变变变"   Margin="25,519,109,21">
            <TextBlock.Foreground>
                <LinearGradientBrush>
                    <GradientStop Color="#FF0000FF" Offset="0.0" />
                    <GradientStop Color="#FFEEEEEE" Offset="1.0" />
                </LinearGradientBrush>
            </TextBlock.Foreground>
            </TextBlock>

FontFamily:字体名称

FontStyle:字体样式

Width:文字区块宽度,可以赋值数字。

Height:文字区块高度,可以赋值数字。

FontWeight:thin extrallight light  normal medium semibold bold extrabold black extrablack

Opacity:文字透明度,赋值为0—1.0

TextWrapping:wrap ,nowrap,wrapwithoverflow

TextBlock是没有Background这个属性的,其实这个现象也说明了一个问题,为了Windows Phone App应用的美观和统一几乎不会需要设置TextBlock的背景。
当然,如果非要设置,还是可以的,比如你可以将TextBlock控件放到一个Grid里面,控制Grid和TextBlock的Height,Width属性相同。这样可以通过设置 Grid元素的背景颜色达到修改TextBlock背景的目的。

<Grid Width="200" Height="200">
                <Grid.Background>
                    <ImageBrush ImageSource="/Image/1.png"></ImageBrush>
                </Grid.Background>
                <TextBlock Width="200" Height="200" Name="text1" Text="aa">
                   <TextBlock.Foreground>
                       <ImageBrush ImageSource="/1.jpg"></ImageBrush>
                   </TextBlock.Foreground>
                </TextBlock>
            </Grid>

三、Button

<!--使用按钮点击事件-->
            <Button Name="button1" Click="button1_Click" Height="72" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="46,47,0,0">事件</Button>
            <!--设置按钮的样式:注意未指定按钮高和宽时,HorizontalAlignment和VerticalAlignment的作用 -->
            <Button Name="button2"
                    Content="样式2"
                    FontSize="48"
                    FontFamily="Arial Black"
                    FontStyle="Italic"
                    BorderBrush="Blue"
                    BorderThickness="10"
                    Background="Red"
                    Foreground="Yellow"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    ></Button>
            <!--图片按钮-->
            <Button   Width="200" Height="200"  HorizontalAlignment="Center"  VerticalAlignment="Center" Margin="61,471,195,97">
                <Image  Stretch="Fill" Height="176"  Width="151" Source="/1.png"></Image>
            </Button>

当然,也可以这么写:

 <!--图片按钮-->
            <Button   Width="200" Height="200"  HorizontalAlignment="Center"  VerticalAlignment="Center" Margin="61,471,195,97">
                <StackPanel>
                <Image  Stretch="Fill" Height="176"  Width="151" Source="/1.png"></Image>
                </StackPanel>
            </Button>

另外,关于按钮的触发事件。

//当然,也可以指定,按钮触发的条件。
        //button有三种状态。press hover release
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            button1.ClickMode = ClickMode.Press;

            MessageBox.Show("测试触发状态1!");
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            button2.ClickMode = ClickMode.Hover;
            MessageBox.Show("测试触发状态2!");
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            button3.ClickMode = ClickMode.Release;
            MessageBox.Show("测试触发状态3!");
        }

不过,,,,感觉不到差别。。。。。。不懂。。。

Windows phone 之常用控件的更多相关文章

  1. C语言Windows程序开发—Windows窗口样式与常用控件样式【第04天】

    (一)Windows窗口(MDICLIENT)样式介绍 /* Windows窗口样式 */ WS_BORDER //带有边框的窗口 WS_CAPTION //带有标题栏的窗口 WS_CHILD //子 ...

  2. Windows Phone开发(11):常用控件(下)

    原文:Windows Phone开发(11):常用控件(下) WP控件大部分都可以从Silverlight中继承过来,这里我也只能拿一部分作演示,对于其它控件如何使用,可以参考SDK相关说明以及Sil ...

  3. Windows Phone开发(10):常用控件(上)

    原文:Windows Phone开发(10):常用控件(上) Windows Phone的控件有几个来源,和传统的桌面应用程序开发或Web开发一样,有默认提供的控件和第三方开者发布的控件.一般而言,如 ...

  4. [WinForm]WinForm跨线程UI操作常用控件类大全

    前言 在C#开发的WinForm窗体程序开发的时候,经常会使用多线程处理一些比较耗时之类的操作.不过会有一个问题:就是涉及到跨线程操作UI元素. 相信才开始接触的人一定会遇上这个问题. 为了解决这个问 ...

  5. 【Windows编程】系列第二篇:Windows SDK创建基本控件

    在Win32 SDK环境下,怎么来创建常用的那些基本控件呢?我们知道如果用MFC,简单的拖放即可完成大多数控件的创建,但是我们既然是用Windows SDK API编程,当然是从根上解决这个问题,实际 ...

  6. 深入Windows窗体原理及控件重绘技巧

    之前有学MFC的同学告诉我觉得Windows的控件重绘难以理解,就算重绘成功了还是有些地方不明白,我觉得可能很多人都有这样的问题,在这里我从Windows窗体的最基本原理来讲解,如果你有类似的疑惑希望 ...

  7. WPF 10天修炼 第六天- 系统属性和常用控件

    WPF系统属性和常用控件 渐变的背景色 WPF中的前景色和背景色不同于传统Winform的设置,这些属性都是Brush类型的值.在XAML中,当为这些属性设置指定的颜色后将被转换为SolidColor ...

  8. C# 常用控件属性及方法介绍

      C#常用控件属性及方法介绍                                               目录 1.窗体(Form) 2.Label (标签)控件 3.TextBox ...

  9. VS2010/MFC编程入门之三十二(常用控件:标签控件Tab Control 上)

    前面两节鸡啄米讲了树形控件Tree Control,本节开始讲解标签控件Tab Control,也可以称为选项卡控件. 标签控件简介 标签控件也比较常见.它可以把多个页面集成到一个窗口中,每个页面对应 ...

随机推荐

  1. 日志配置logback

    在选择项目日志框架时,发现log4j的作者开发了新的日志框架,据说性能提高不少,那就选它了,不过,除了配置上有点不习惯外,最重要的一点 ,打印线程号这个功能依然没有(打印线程名这个东西是在是个鸡肋). ...

  2. Tornado源码探寻(开篇)

    一.先从一个简单的socket说起 运行脚本并在浏览器上访问http://127.0.0.1:8080 #!/usr/bin/env python #coding:utf-8 import socke ...

  3. What does wildcard address in InetSocketAddress mean?

    In the docs for the constructor InetSocketAddress(int port) it says: Creates a socket address where ...

  4. Java Networking: InetAddress

    The InetAddress is Java's representation of an IP address. Instances of this class are used together ...

  5. UVA 10194 Football (aka Soccer)

     Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (america ...

  6. UVA 10047 The Monocycle (状态记录广搜)

    Problem A: The Monocycle  A monocycle is a cycle that runs on one wheel and the one we will be consi ...

  7. S2SH邮件注册激活后注册成功

    首先我的思路是这样的:①接收从客户端接收过来的数据(密码,用户名,邮箱) ②将密码进行MD5加密,然后将信息用"_"连接起来(用于后面分解) ③将信息交个一个工具类中实现生成邮件信 ...

  8. table 的thead th 固定 tbody滚动例子

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  9. wDatePicker使用说明文档

    版权声明:本文为博主原创文章,未经博主允许不得转载. http://www.my97.net/dp/demo/ 4.5更新的内容 [重构]对WdatePicker.js做了较大规模的调整 [改进]自动 ...

  10. Linux下设置最大文件打开数nofile及nr_open、file-max

    在开发运维的时候我们常常会遇到类似“Socket/File: Can’t open so many files”,“无法打开更多进程”,或是coredump过大等问题,这些都可以设置资源限制来解决.今 ...