0
我有一個切換按鈕,其格式如下。事情是當我點擊按鈕圖像變化很好。只有當我懸停在它上面時,劑量似乎改變了圖像。請幫我做錯了什麼。我也嘗試從代碼behing MouseEnter,但仍然是劑量工作。觸發器屬性IsMouseOver不能在ToggleButton上工作
<ToggleButton Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" Panel.ZIndex="140" Height="41" Width="35" FontSize="9" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderThickness="0">
<Image Source="/AltusClient;component/Images/EasyLocate_open.png" Height="41" Width="35"></Image>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="ToggleButton.IsMouseOver" Value="True">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderThickness="0">
<Image Source="/AltusClient;component/Images/EasyLocate_hover.png" Height="41" Width="35"></Image>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderThickness="0">
<Image Source="/AltusClient;component/Images/EasyLocate_open.png" Height="41" Width="35"></Image>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderThickness="0">
<Image Source="/AltusClient;component/Images/EasyLocate_closed.png" Height="41" Width="35"></Image>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
<!--<ToggleButton.Template>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Content">
<Setter.Value>
<Border BorderThickness="0">
<Image Source="/AltusClient;component/Images/EasyLocate_hover.png" Height="41" Width="35"></Image>
</Border>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>-->
</ToggleButton>
沒有URL是好的。相同的URL適用於檢查和未檢查的命令。我也使用了xaml.cs中的鼠標輸入事件。當我把一箇中斷點擊中斷點。圖像不是空的。它包含圖像,但從未顯示何時懸停。 – nikhil
使用這個完全相同的uri作爲獨立的圖像控件。 – AnjumSKhan
我已經嘗試了一切。我想我需要重寫我不確定的默認按鈕模板。我試圖用不同的網址替換源文件。我用背景來玩弄transsparent,{x:Nul}等等,但仍然是一些無用的工作。也嘗試過controltemplate.triggers做模板,但仍然沒有運氣。 我嘗試了一些正常按鈕的鏈接。與此問題只是懸停工程,但IsPressed真正或假的劑量工作。 https://social.msdn.microsoft.com/Forums/vstudio/en-US/bfb9d5d0-c526-4c34-b675-84020d2de189/buuton-ismouseover-trigger-not-working?forum=wpf – nikhil