如何在Windows Phone媒体查看器中显示图像?

时间:2015-01-08 05:18:19

标签: c# xaml windows-phone-8 bitmap

我正在尝试使用Windows phone media viewer nuget包显示位图图像。

我的代码示例:

xaml代码:

<controls:MediaViewer x:Name="MediaViewer"
                      InitiallyDisplayedElement="First" />

c#c​​ode:

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媒体查看器中显示位图图像?

0 个答案:

没有答案