如何从XAML调用函数

时间:2013-05-01 11:40:11

标签: wpf xaml

我有以下xaml代码:

<Window.Triggers>
    <EventTrigger RoutedEvent="MouseEnter">
        <EventTrigger.Actions>
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.5" Storyboard.TargetName="BackgroundBrush" From="0.5">
                    </DoubleAnimation>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger.Actions>
    </EventTrigger>

另外,我想在引发MouseEnter时调用某个函数

    void UpdateTimeAfterMouseOver()
    {
        timeAfterLastMouseOver = _timeAfterLastMouseOver_init;
    }

怎么做?我通过命令模型对其进行成像,但无法成像如何:)

1 个答案:

答案 0 :(得分:2)

我只想使用MouseEnter Event

<Window MouseEnter="OnMouseEnterHandler"

void OnMouseEnterHandler(object sender, MouseEventArgs e)
{
    ...
}