我正在使用新的预览版sdk 16190创作者的更新,如BUILD 2017中所述。
我在MVVM模式下绑定了一个gridview,但是它没有工作,所以我把它简化为直接代码,知道真正的问题,我甚至使用了一个断点,看起来断点永远不会受到影响该行永远不会执行,因此gridview项目源仍为空。
此外,我尝试了x:绑定gridview项目源,它也不起作用。它真的令人沮丧,因为它没有任何意义。以下是我的代码
public VideoLibraryPage()
{
InitializeComponent();
VideoItems = new ObservableCollection<VideoItem>();
}
public ObservableCollection<VideoItem> VideoItems { get; set; }
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
var files = await KnownFolders.VideosLibrary.GetFilesAsync();
foreach (var file in files)
{
var bit = new BitmapImage();
bit.SetSource( await file.GetThumbnailAsync(ThumbnailMode.VideosView));
//breakpoint on below line never gets hit, so not even a single item is added to VideItems collection.
VideoItems.Add(new VideoItem
{
Title = file.DisplayName,
Display = bit
});
}
VideosLibraryGridView.ItemsSource = VideoItems;
}
public class VideoItem
{
public string Title { get; set; }
public string Views { get; set; }
public string Duration { get; set; }
public ImageSource Display { get; set; }
public StorageFile MyVideoFile { get; set; }
}
XAML
<controls:AdaptiveGridView Name="VideosLibraryGridView" Grid.Row="1"
Header="Videos"
Style="{StaticResource MainGridView}"
ItemClick="VideosLibraryGridView_ItemClicked"
>
<controls:AdaptiveGridView.ItemTemplate>
<DataTemplate x:DataType="data:VideoItem">
<StackPanel Margin="4" >
<Grid>
<Image Source="{x:Bind Display, Mode=OneWay}" Style="{StaticResource GridViewImage}"/>
<Border Style="{StaticResource TimeBorder}">
<TextBlock Text="{x:Bind Duration, Mode=OneWay}" Foreground="White"/>
</Border>
</Grid>
<TextBlock Text="{x:Bind Title ,Mode=OneWay}" Style="{StaticResource GridViewVideoName}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
<TextBlock Text="{x:Bind Views, Mode=OneWay}" Style="{StaticResource GridViewViews}"/>
<TextBlock Text="Views" HorizontalAlignment="Right"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</controls:AdaptiveGridView.ItemTemplate>
</controls:AdaptiveGridView>
答案 0 :(得分:0)
问题只是我的RAM,最新的内部人员SDK使用更多的RAM,我不得不重启我的机器来清除RAM然后它工作正常