1

MainPage.cs に selectionChanged イベント ハンドラーを書きましたが、ピボット ページを変更しても反応しません。

 private void MainPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    Debug.WriteLine("Pivot selection changed");
    switch (((Pivot)sender).SelectedIndex)
    {
        case 0:
            Debug.WriteLine("LoginAppBar launched");
            ApplicationBar = ((ApplicationBar)Application.Current.Resources["LoginAppBar"]);
            break;

        case 1:
            Debug.WriteLine("DefaultAppBar launched");
            ApplicationBar = ((ApplicationBar)Application.Current.Resources["AppBar"]);
            break;

        case 2:
            Debug.WriteLine("DefaultAppBar launched");
            ApplicationBar = ((ApplicationBar)Application.Current.Resources["AppBar"]);
            break;
    }
}

このイベント ハンドラーが機能しないのはなぜですか? メソッドの名前ですか?method-header を private void に変更してみましたmyNameSpaceHere_SelectionChanged(object sender, SelectionChangedEventArgs e)

しかし、それでもイベントをキャッチしません。

任意のヒント?

4

1 に答える 1

1

了解しました。XAMLを編集しませんでした:

 <controls:Pivot Title="APP"
                        x:Name="Pivot"
                        SelectionChanged="Pivot_SelectionChanged"
                        Foreground="#FF72BCE6"
                        BorderThickness="2">

SelectionChanged属性を追加する必要がありました。

于 2012-09-09T11:57:49.710 に答える