1

Какое событие в тригерах отвечает за клик? Хочу сделать чтобы при нажатии на картинку она увеличивалась, а при отпускании нажатия уменьшалась.

<Grid.Style>
    <Style TargetType="Image">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Width" Value="100"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Grid.Style>

1 ответ 1

2

Используйте EventTrigger, я покажу на примере TextBlock:

<Grid>
    <Grid.Resources>
        <Style TargetType="TextBlock">
            <Style.Triggers>
                <EventTrigger RoutedEvent="MouseLeftButtonDown">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetProperty="FontSize"
                                                 To="32" Duration="0:0:1"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
                <EventTrigger RoutedEvent="MouseLeftButtonUp">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetProperty="FontSize"
                                                 To="13" Duration="0:0:1"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Style.Triggers>
        </Style>
    </Grid.Resources>
    <TextBlock Text="Some Text" FontSize="13"
               HorizontalAlignment="Center"
               VerticalAlignment="Center"/>
</Grid>

Animation

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.