Windows Phone7開發之 按鈕控件

webphp 12年前發布 | 21K 次閱讀 Windows Phone開發 移動開發 Windows Phone

一.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: 超鏈接按鈕,這個按鈕可以navigate本地和web

<HyperlinkButton Content="HyperlinkButton" Height="61" HorizontalAlignment="Left" Margin="111,117,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="233" NavigateUri="/Windows1.xaml" >

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

<HyperlinkButton Content="HyperlinkButton" Height="48" HorizontalAlignment="Left" Margin="88,459,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="238" NavigateUri="http://www.baidu.com/myZoom/dzcoutput.xml" TargetName="_self" />

 三.RepeatButton: 可以在按下后,不斷的發出click事件。這樣就可以完成不斷需要變化的需求了,如翻頁、移動等。

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

 四.ToggleButton: 觸發按鈕,可以使按鈕有二種(CheckedUnChecked)還是三種狀態(多了一個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>

 本文由用戶 webphp 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!