[Winodows Phone 7控件详解]按钮控件

在Silverlight中有多种按钮控件,这些控件在Windows phone7中也都得到了很好的支持。

一.Button这个控件只是一个基础控件,通过blend可以创建出多种效果的按钮来。

            <Button Content="Button1" Height="81" HorizontalAlignment="Left" Margin="135,45,0,0" Name="button1" VerticalAlignment="Top" Width="213" Click="button1_Click"  Background="Blue" Foreground="Beige" BorderBrush="Yellow" BorderThickness="5"  />
<Button Content="Button2" Height="81" HorizontalAlignment="Left" Margin="135,132,0,0" x:Name="button2" VerticalAlignment="Top" Width="213" Foreground="Beige" BorderBrush="Yellow" BorderThickness="5" >
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="#FF000000" Offset="0.543"/>
<GradientStop Color="#FFFFFFFF" Offset="0.996"/>
<GradientStop Color="Red" Offset="0.03"/>
</LinearGradientBrush>
</Button.Background>
</Button>
<Button Content="Button3" Height="81" HorizontalAlignment="Left" Margin="135,219,0,0" x:Name="button3" VerticalAlignment="Top" Width="213" Foreground="Beige" BorderBrush="Yellow" BorderThickness="5" ClickMode="Press" >
<Button.Background>
<ImageBrush ImageSource="Images/1.jpg" Stretch="UniformToFill"/>
</Button.Background>
</Button>

二.HyperlinkButton: 超链接按钮,这个按钮可以navigate本地和web。

HyperlinkButton Content="Click here to learn about Silverlight"
NavigateUri="http://www.silverlight.net" TargetName="_blank" Margin="22,270,-12,239"/>

NavigateUri:如果不指定TargetName属性,就只能用Relative的链接。

三.RepeatButton可以在按下后,不断的发出click事件。这样就可以完成不断需要变化的需求了,如翻页、移动等。

<RepeatButton Content="RepeatButton" Height="100" HorizontalAlignment="Left" Margin="84,374,0,0" Name="repeatButton1" VerticalAlignment="Top" Width="315"  Click="repeatButton1_Click"/>           

四.ToggleButton:触发按钮,可以使按钮有二种(CheckedUnChecked)还是三种状态(多了一个Indeterminate状态)

<ToggleButton  Content="ToggleButton" Height="127" HorizontalAlignment="Left" Margin="103,474,0,0" Name="toggleButton1" VerticalAlignment="Top" Width="268" IsThreeState="True" Checked="toggleButton1_Checked" Unchecked="toggleButton1_Unchecked"  Indeterminate="toggleButton1_Indeterminate"/>

IsThreeState:设置是否有三种状态

原文地址:https://www.cnblogs.com/DebugLZQ/p/2422850.html