WP7中自定义按钮全局样式资源并绑定到按钮

1. 在MainPage.xaml中定义按钮的全局样式:边界颜色为红色,前景色为黄色

  1. <phone:PhoneApplicationPage.Resources>  
  2.     <Style x:Key="BtnStyle" TargetType="Button">  
  3.         <Setter Property="BorderBrush" Value="Red" />  
  4.         <Setter Property="Foreground" Value="Yellow" />  
  5.     </Style>  
  6. </phone:PhoneApplicationPage.Resources>  

2. 绑定至按钮

  1. <Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="134,137,0,0" Name="button1" VerticalAlignment="Top" Width="160" Style="{StaticResource BtnStyle}" />  

3. 运行效果

posted @ 2012-05-09 17:07  微笑的''80  阅读(202)  评论(0)    收藏  举报