0
我正在開發一個WPF項目。如果Button的isMouseHover爲true,我想在按鈕上刪除突出顯示(如圖中藍色)。我不確定它是否被稱爲高亮。也許這可能是效果,焦點等。我添加BorderBrush是透明的,但它沒有工作。代碼如下:如何在wpf中IsMouseHover爲true時刪除按鈕上的突出顯示
<Image x:Key="LoginImg" Source="..\Images\Login\oturumac.png"
Stretch="Fill"/>
<Image x:Key="LoginImg_RollOver" Source="..\Images\Login\oturumac_rollover.png"
Stretch="Fill"/>
<Style x:Key="LoginButtonStyle" TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Content" Value="{DynamicResource LoginImg_RollOver}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Content" Value="{DynamicResource LoginImg}"/>
</Trigger>
</Style.Triggers>
</Style>
圖片如下。第一張照片時IsMouseOver爲真:
我該如何解決?
按鈕代碼如下:
<Button Background="Transparent" BorderBrush="Transparent" Style="{DynamicResource LoginButtonStyle}" Click="btnLogin_Click" HorizontalAlignment="Center" VerticalAlignment="Top" Width="180" Grid.Column="1" Grid.Row="4" x:Name="btnLogin" TabIndex="2"/>
我看到了Sheridan提到的問題,但我解決不了問題。因爲我不選擇或點擊按鈕。只有我將鼠標拖放到按鈕上。按鈕周圍是突出顯示。 –
我的歉意......我誤解了你的問題,並沒有意識到它是一個'Button'。我現在已經重新提出了你的問題。你需要顯示你的'Button'的代碼,以便我們能夠確定你做錯了什麼。當你真的只想改變'Background'顏色時,好像你正在改變'Content'屬性? – Sheridan
我只想改變圖像。但按鈕突出顯示。 Background和BorderBrush是透明的 –