Reputation: 7601
I have two buttons Which is menioned in image
I have set the styles on it like
<Window.Resources>
<Style x:Key="LinkButton" TargetType="Button">
<Setter Property="Foreground" Value="Blue" />
<Setter Property="Cursor" Value="Hand" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}}"
Value="True">
<Setter Property="TextElement.Foreground" Value="White"/>
</DataTrigger>
<EventTrigger RoutedEvent="Click">
<BeginStoryboard>
<Storyboard RepeatBehavior="100">
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.2" To="0.2" ></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Button Height="50" Width="52" Content="123" Style="{DynamicResource LinkButton}" Margin="64,42,401,227"/>
<Button Height="50" Width="52" Content="456" Style="{DynamicResource LinkButton}" Margin="137,42,328,227"/>
</Grid>
the prob is when I click on first button 123 button the Opacity is set 0.2 which is good but I want when I click on 456 then 123 become normal and Opacity of 456 become a 0.2 how can I achive this.
Upvotes: 0
Views: 98
Reputation: 22956
Sounds like you want the opacity to change only when the button has the focus. In this case you do not want to use an EventTrigger based on the Click event. Instead you want to use something like...
<Trigger Property="IsFocused" Value="True">
<Setter Property="Visibility"
TargetName="border"
Value="Collapsed"/>
</Trigger>
Upvotes: 2
Reputation: 176
I would probably add a btn click handler which would set some variable to this button clicked and when you click another button you reset the opacity to 1 of the previous pressed button.
Upvotes: 0