如何在Pivot_SelectionChanged中捕获AutoSuggestBox事件?

时间:2016-06-17 15:45:13

标签: c# wpf uwp

private void SuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {

            if(args.QueryText!=null)
            {
                ...

            }

        }
Pivot_SelectionChanged
private void privotContent_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            SuggestBox.QuerySubmitted += SuggestBox_QuerySubmitted;
        }

不要在privotContent中调用SuggestBox.QuerySumitted。但我想这样做。

1 个答案:

答案 0 :(得分:1)

我想您要在QuerySubmitted控件的AutoSuggestBox事件内触发SelectionChanged的{​​{1}}事件。例如,您可以使用以下代码:

Pivot

此代码中的private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e) { var ee = new AutoSuggestBoxQuerySubmittedEventArgs(); AutoSuggestBox_QuerySubmitted(autoSuggestBox, ee); } private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { if (args.QueryText != null) { } } autoSuggestBox控件的Name