ピボット コントロールのアイテムとして保持したい約 30 の画像があります。SO私はピボットを動的に追加していました.今、いくつかの制限を超えた場合、ピボット項目を削除したいのですが、ピボット選択を変更するとInvalidExceptionが発生します. スニペットの pivotshow はピボット コントロールです。
    void PivotShow_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        AddItems();
    }
    private void AddItems()
    {
        PivotItem toadd = PivotGen(images[i]);
        i = (i + 1) % (images.Length);
        PivotShow.Items.Add(toadd);
        try
        {
            if (PivotShow.Items.Count > 3)
                PivotShow.Items.RemoveAt(0);
        }
        catch (InvalidOperationException)
        {
            MessageBox.Show("Operation not allowed");
        }
    }
    private PivotItem PivotGen(string urlimage)
    {
        PivotItem p = new PivotItem();
        p.Margin = new Thickness(0, -90, 0, 0);
        Image img = new Image();
        BitmapImage bmp = new BitmapImage(new Uri(urlimage, UriKind.Relative));
        img.Stretch = Stretch.Fill;
        img.Source = bmp;
        p.Content = img;
        return p;
        //PivotShow.Items.Add(p);
    }
前もって感謝します