在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>