在XAML中定义交互行为时,应用程序崩溃

时间:2014-08-21 10:50:00

标签: xaml winrt-xaml windows-8.1 windows-phone-8.1 expression-blend

我发现在XAML中定义了交互行为时,我的应用程序崩溃了。

弹出控件可以有交互行为吗?

XAML:

<AppBarButton Icon="Find" Label="Find">
    <Button.Flyout>
        <Flyout x:Name="SearchFlyout">

            <Interactivity:Interaction.Behaviors>
                <Core:EventTriggerBehavior EventName="Opened">
                    <behaviors:FlyoutOpenedAction />
                </Core:EventTriggerBehavior>
            </Interactivity:Interaction.Behaviors>

            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <TextBox x:Name="Searchbox" PlaceholderText="contact's name" Width="250" 
                         IsTextPredictionEnabled="False"
                         IsSpellCheckEnabled="False"
                         VerticalAlignment="Center">

                    <Interactivity:Interaction.Behaviors>
                        <Core:EventTriggerBehavior EventName="KeyUp">
                            <behaviors:FilterContactAction />
                        </Core:EventTriggerBehavior>
                    </Interactivity:Interaction.Behaviors>
                </TextBox>
            </StackPanel>
        </Flyout>
    </Button.Flyout>
</AppBarButton>

代码:

public class FlyoutOpenedAction : DependencyObject, IAction
{
    public object Execute(object sender, object parameter)
    {
        var searchBox = ResourceLocator.Instance[typeof(TextBox)] as TextBox;
        searchBox.Text = string.Empty;

        return null;
    }
}

0 个答案:

没有答案