1

Silverlight 5 で PivotViewer コントロールをいじっているだけです。多くのことが改善されたようですが、.cxmlSilverlight 4 で完全に機能していた古いコレクションを表示する際に問題が発生しています。

古いコーディング方法:

InitializeComponent();
MainPivotViewer.LoadCollection("http://localhost:4573/ClientBin/Actresses.cxml",              string.Empty);

は次のように変換されます。

InitializeComponent();
CxmlCollectionSource _cxml = new CxmlCollectionSource(new Uri("http://localhost:1541/ClientBin/Actresses.cxml", UriKind.Absolute));
PivotMainPage.PivotProperties = _cxml.ItemProperties.ToList();
PivotMainPage.ItemTemplates = _cxml.ItemTemplates;
PivotMainPage.ItemsSource = _cxml.Items;

何が起こるかというと、アイテムは表示されますが、フィルター ペインには何も表示されず、アイテムが選択されている場合、それらの説明はもうありません!

4

1 に答える 1

2

何が起こっているかというと、ファイルをダウンロードして処理する_cxml.ItemsPropertiesまでロードされません。 イベントがあります。が であるかどうかを確認すると、プロパティを PivotViewer にマップできます。CxmlCollectionSource.cxmlCxmlCollectionSourceStateChangedStateLoaded_cxml

これがどのように見えるかのサンプルを次に示します。

        private CxmlCollectionSource _cxml;
    void pViewer_Loaded(object sender, RoutedEventArgs e)
    {
        _cxml = new CxmlCollectionSource(new Uri("http://myurl.com/test.cxml",
                                             UriKind.Absolute));
        _cxml.StateChanged += _cxml_StateChanged;
    }

    void _cxml_StateChanged(object sender,
                           CxmlCollectionStateChangedEventArgs e)
    {
        if(e.NewState == CxmlCollectionState.Loaded)
        {
            pViewer.PivotProperties =
                       _cxml.ItemProperties.ToList();
            pViewer.ItemTemplates =
                       _cxml.ItemTemplates;
            pViewer.ItemsSource =
                       _cxml.Items;
        }
    }

これについては、ブログでさらに詳しく説明しています。

于 2012-03-29T14:09:30.507 に答える