2009-06-01 25 views

回答

6

內所需的事件,你可以設置背景顏色像這樣...

// Change the background color of button1 to Blue 
button1.Background = Brushes.Blue; 

您還可以設置這觸發:

<!-- Button will change from Blue to Yellow on MouseOver --> 
<Style TargetType="{x:Type Button}"> 
    <Setter Property="Background" Value="Blue" /> 
    <Style.Triggers> 
     <Trigger Property="IsMouseOver" Value="True"> 
      <Setter Property="Background" Value="Yellow" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

如需更多詳細資料,請瀏覽屬性觸發器部分this文章。

+2

此問題可以在這個問題中找到: http://stackoverflow.com/questions/1302756/why-is-the-buttons-background-changing 同樣的問題發生在我身上 - 它會似乎沒有設置背景。 – JJO 2009-08-20 23:26:46

相關問題