我有一个自定义按钮,其中包括一个股票代码和一个图像。当我想单击按钮时,除了 onMouseover 之外,一切都完全按照我的需要工作。如果我将鼠标悬停在不包含文本框的按钮(包括图像)的任何部分上,则整个按钮(光标手)会显示。因此,单击股票代码(十字准线不显示手形光标)不会执行我的命令。我错过了一些愚蠢的东西,我只是不能把手指放在上面。任何帮助将不胜感激。这是来自我的资源字典:
<Style x:Key="TickerButtonStyle2" TargetType="{x:Type Controls:DataGridCell}">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Button>
<Button.Resources>
<Style TargetType="Button">
<Setter Property="Command" Value="{Binding SwitchViewCommand,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type local:MainView}}}" />
<Setter Property="CommandParameter" Value="{Binding Ticker}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="bd" BorderBrush="Transparent"
BorderThickness="0"
Margin="0"
Background="Transparent">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" Background="Transparent">
<TextBox Name="txt" IsReadOnly="True"
BorderThickness="0"
BorderBrush="Transparent"
Background="Transparent"
TextAlignment="Left"
Foreground="White"
FontFamily="Ariel"
FontSize="12"
Text="{Binding Path=Ticker, Converter={StaticResource tickerSymbolDisplay}}"
/>
<Image Width="16" Height="11" Stretch="Fill" Source="{Binding Path=Ticker, Converter={StaticResource tickerImageDisplay}}" />
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="bd" Property="Background" Value="Transparent"/>
<Setter TargetName="txt" Property="Foreground" Value="#FF7E00"/>
<Setter Property="ToolTip" Value="View Fundamentals"/>
</Trigger>
<Trigger Property="Button.IsPressed" Value="true">
<Setter TargetName="bd" Property="Background" Value="Transparent"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Resources>
</Button>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>