2013-02-13 112 views
1

我在我的應用程序創建圖像的按鈕:按鍵採用圖像藍色背景

   <Button x:Name="favoriteButton" HorizontalAlignment="Left" VerticalAlignment="Top" Height="72" Width="99" Click="DidPressAddToFavorites" BorderBrush="{x:Null}" Foreground="{x:Null}"> 
        <Button.Background> 
         <ImageBrush ImageSource="/Images/[email protected]" Stretch="Uniform"/> 
        </Button.Background> 
       </Button> 

而且我注意到,當用戶按下按鈕按鈕變成藍色,當我鬆開按鈕,我再次看到它。任何想法如何解決它?

編輯:

這是處理方法:

private void DidPressAddToFavorites(object sender, RoutedEventArgs e) 
    { 
     if (favoriteRep.ExistInFavorites(currentItem) == true) 
     { 
      this.SetButtonWithImage(favoriteButton, "/Images/[email protected]"); 
      favoriteRep.RemoveFromFavorites(currentItem); 
     } 
     else 
     { 
      this.SetButtonWithImage(favoriteButton, "/Images/[email protected]"); 
      favoriteRep.AddToFavorites(currentItem); 
     } 

    } 
+0

編輯模板,你能告訴我們更多,或者顯示在DidPressAddToFavorites上執行的代碼嗎? – 2013-02-13 09:17:11

+0

我加了這個方法, – MTA 2013-02-13 09:20:11

回答

0

因爲你沒有加國,有三種狀態正常,鼠標懸停,按下......你必須設置圖像對於所有三個州來說,使它符合你的願望。這裏的替代方案是,不知道從c#中獲得的更好的方法,只需在事件和新聞事件中添加兩個eventHndlers Mouse,然後在其中設置圖像...。 那麼還有另一個好辦法,就是嘗試從混合軟件

+0

我在哪裏可以找到這個狀態? – MTA 2013-02-17 11:12:05