【飞秋】一起学Windows Phone7开发(十三.二 按钮控件)
在Silverlight中有多種按鈕控件,這些控件在Windows phone7中也都得到了很好的支持。
一.Button: 這個控件只是一個基礎控件,通過blend可以創建出多種效果的按鈕來。
<Button Content="Button1" Height="81" HorizontalAlignment="Left" Margin="135,99,0,0" Name="button1" VerticalAlignment="Top" Width="213" Click="button1_Click"? Background="Red" Foreground="Beige" BorderBrush="Yellow" BorderThickness="5"? />
Click:響應點擊的事件。
?
通過使用blend工具可以設置按鈕的多種效果:
<Button Content="Button2" Height="81" HorizontalAlignment="Left" Margin="135,237,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="#FFF9F9F9" Offset="0.543"/>
?????????????????????????????????? <GradientStop Color="#FFF90808" Offset="0.996"/>
?????????????????????????????????? <GradientStop Color="Red" Offset="0.03"/>
???????????????????????? </LinearGradientBrush>
??????????????? </Button.Background>
??????????? </Button>
??????????? <Button Content="Button3" Height="81" HorizontalAlignment="Left" Margin="135,394,0,0" x:Name="button3" VerticalAlignment="Top" Width="213" Foreground="Beige" BorderBrush="Yellow" BorderThickness="5" ClickMode="Press"? >
??????????????? <Button.Background>
???????????????????????? <ImageBrush ImageSource="/Chrysanthemum.jpg" Stretch="UniformToFill"/>
??????????????? </Button.Background>
??????????? </Button>
?
?
二.HyperlinkButton: 超鏈接按鈕,這個和silverlight有明顯的區別,在wp7中是不能navigate到web的。
<HyperlinkButton Content="HyperlinkButton" Height="61" HorizontalAlignment="Left" Margin="111,117,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="233" NavigateUri="/Windows1.xaml" >
NavigateUri:只能用Relative的鏈接。
?三.RepeatButton: 可以在按下后,不斷的發出click事件。這樣就可以完成不斷需要變化的需求了,如翻頁、移動等。
<RepeatButton Content="RepeatButton" Height="100" HorizontalAlignment="Left" Margin="76,196,0,0" Name="repeatButton1" VerticalAlignment="Top" Width="315"? Click="repeatButton1_Click"/>
?四.ToggleButton: 觸發按鈕,可以使按鈕有二種(Checked、UnChecked)還是三種狀態(多了一個Indeterminate狀態)。
<ToggleButton? Content="ToggleButton" Height="182" HorizontalAlignment="Left" Margin="104,177,0,0" Name="toggleButton1" VerticalAlignment="Top" Width="268" IsThreeState="True" Checked="toggleButton1_Checked" Unchecked="toggleButton1_Unchecked"? Indeterminate="toggleButton1_Indeterminate"/>
IsThreeState:設置是否有三種狀態
?
?
?
?
?<Button.Content>
??? <Image Source="Chrysanthemum.jpg"/>
?</Button.Content>
?關注技術文章飛秋:http://www.freeeim.com/,24小時專業轉載。
總結
以上是生活随笔為你收集整理的【飞秋】一起学Windows Phone7开发(十三.二 按钮控件)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: XEIM 配置程序源代码
- 下一篇: 小波的秘密5_多分辨率分析和连续小波变换