0

如何获得这个 CallMethodAction 方法 InitBlah?目前它不火。我怀疑它的签名是错误的:

<Grid x:Name="LayoutRoot">
    <Button x:Name="btnEnter" Content="Enter" HorizontalAlignment="Left" Height="48" Margin="96,88,0,0" VerticalAlignment="Top" Width="144">
        <interactivity:Interaction.Triggers>
            <interactivity:EventTrigger EventName="MouseEnter" SourceName="btnEnter">
                <interactions:ChangePropertyAction PropertyName="Visibility" Value="Visible" TargetName="TextBoxTest" />
                <interactions:CallMethodAction MethodName="InitBlah" TargetObject="{Binding}"/>
            </interactivity:EventTrigger>

            <interactivity:EventTrigger EventName="MouseLeave" SourceName="btnEnter">
                <interactions:ChangePropertyAction PropertyName="Visibility" Value="Collapsed" TargetName="TextBoxTest" />
            </interactivity:EventTrigger>
        </interactivity:Interaction.Triggers>
    </Button>

    <Grid>
        <TextBlock Name="TextBoxTest" Width="100" Height="100" Visibility="Collapsed">Hello</TextBlock>

后面的代码:

 public void InitBlah(object sender, RoutedEventArgs e)
        {
            var x = 1;
        }

ChangePropertyAction 工作正常:当我将鼠标悬停在按钮上时,会弹出文本框打招呼。

在此处输入图像描述

4

1 回答 1

0

您的方法的签名InitBlah应该与适当的事件相匹配。试试这个:

public void InitBlah(object sender, MouseEventArgs e)
{
    var x = 1;
}
于 2012-12-09T06:49:24.360 回答