我正在尝试使用Windows phone media viewer nuget包显示位图图像。
我的代码示例:
xaml代码:
<controls:MediaViewer x:Name="MediaViewer"
InitiallyDisplayedElement="First" />
c#code:
ObservableCollection<object> slideShowImages = new ObservableCollection<object>();
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string filepath = "Assets";
DirectoryInfo d = new DirectoryInfo(filepath);
foreach (var file in d.GetFiles("*.png"))
{
Image img = new Image();
img.Source = new BitmapImage(new Uri("/" + filepath + "/" + file.Name, UriKind.Relative));
slideShowImages.Add(img);
}
MediaViewer.Items = slideShowImages;
}
但在媒体浏览器中,我只得到一个黑屏。有没有办法在Windows Phone媒体查看器中显示位图图像?