I have a user control in WPF in which I define a large ItemsControl template. There I have a Grid and in one column of this grid, I have a TextBlock, and in another column I have a Border.
I want to highlight the border when the mouse enters the TextBlock.
I tried several scenarios: first an EventTrigger in the TextBlock style, but I found out that you cannot do this, then an EventTrigger in the TextBlock trigger section, and now I just put it in the DataTemplate.Triggers of my ItemsControl, but I keep getting Error:
"Cannot resolve all property references in the property path 'Border.BorderBrush.Color'. Verify that applicable objects support the properties."
Here is the code causing the problems:
<DataTemplate.Triggers> <EventTrigger SourceName="mytxtblock" RoutedEvent="TextBlock.MouseEnter"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard> <ColorAnimation Storyboard.TargetName="myborder" Storyboard.TargetProperty="Border.BorderBrush.Color" Duration="0:0:1" To="White" /> <ThicknessAnimation Storyboard.TargetProperty="Border.BorderThickness" Duration="0:0:1" From="0" To="1" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </DataTemplate.Triggers>
I think I'm missing something in the way I relate to the Color property of my border, any understanding?
Thanks!
EDIT : I realized that the SolidColorBrush in Resources and then using this value allows me to get rid of
Storyboard.TargetProperty="Border.BorderBrush.Color" , which changes to Storyboard.TargetProperty="Border.BorderBrush" ,
but now the compiler tells me that the declared color (I tried Green and Transparent) is not a valid value for "To" ...
source share