使用Data Virtualization设置FlipView Items源的问题

时间:2016-05-20 15:27:50

标签: data-binding uwp uwp-xaml flipview data-virtualization

这是我之前的问题(UWP Problems Setting GridView Items source using x:Bind)的后续跟进。

在这种情况下,我使用的是来自Mirosoft Data virtualization sample的随机访问文件数据源,并且从未填充网格。问题在于我没有提高财产变更事件。网格现在运作良好。

我现在的问题是,我试图在翻转视图控件中使用数据源而不是网格视图。数据源确实已初始化,更改属性通知已引发,但翻转视图中未显示任何内容。

翻转视图是否可以显示虚拟馆藏中的数据?

这是我的模型代码:

public class PhotoFlipViewViewModel : Mvvm.ViewModelBase
{

    private FileDataSource _PicturesCollection;

    public FileDataSource PicturesCollection
    {
        get
        {
            return _PicturesCollection;
        }
        set
        {
            if (_PicturesCollection != value)
            {
                _PicturesCollection = value;
                RaisePropertyChanged(() => PicturesCollection);                   
            }
        }
    }

    public PhotoFlipViewViewModel()
    {
         initdata();
    }

     async void initdata()
    {
        StorageLibrary pictures = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);
        string path = pictures.SaveFolder.Path;

        var source = await FileDataSource.GetDataSoure(path);
        if (source.Count > 0)
        {
            PicturesCollection = source;
        }
    }

    public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary<string, object> suspensionState)
    {

        System.Diagnostics.Debug.WriteLine("PhotoFlipViewViewModel::OnNavigatedToAsync - event fired.");

        if ( SessionState.ContainsKey("SelectedPhotoObjectFromGrid"))
        {

        await Task.CompletedTask;
    }

    public override async Task OnNavigatedFromAsync(IDictionary<string, object> suspensionState, bool suspending)
    {
        if (suspending)
        {
        }
        await Task.CompletedTask;
    }

    public override async Task OnNavigatingFromAsync(NavigatingEventArgs args)
    {
        args.Cancel = false;
        await Task.CompletedTask;
    }
}

我在XAML中的FlipView:

    <FlipView x:Name="PhotoOuterFlipView"
                  BorderBrush="Black"
                  BorderThickness="1"
                  VerticalAlignment="Top"
                  HorizontalAlignment="Stretch"
                  ItemsSource="{x:Bind ViewModel.PicturesCollection, Mode=OneWay}"                     
                  ItemTemplate="{StaticResource PictureFlipViewTemplate}">
    <FlipView.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </FlipView.ItemsPanel>
</FlipView>

谢谢,任何建议都表示赞赏。

0 个答案:

没有答案