从Windows商店应用程序清除图像

时间:2013-11-21 13:21:46

标签: c# image windows-store-apps

我正在通过功能将图像插入我的Windows应用商店:

private async void Button_Click(object sender, RoutedEventArgs e)
    {

        FileOpenPicker openPicker = new FileOpenPicker();
        openPicker.ViewMode = PickerViewMode.Thumbnail;
        openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;

        openPicker.FileTypeFilter.Clear();
        openPicker.FileTypeFilter.Add(".jpg");
        openPicker.FileTypeFilter.Add(".jpeg");
        openPicker.FileTypeFilter.Add(".png");

        StorageFile file = await openPicker.PickSingleFileAsync();
        if (file != null)
        {
            using(IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
            {

                await bitmapImage.SetSourceAsync(fileStream);

                ImageBox.Source = bitmapImage;
            }            
        }
    }

我希望有一个方法可以清除ImageBox中的图像。在Google上做了一些研究我发现使用:

ImageBox.Image = false;

我的*.image中没有ImageBox属性,我还能如何实现?

1 个答案:

答案 0 :(得分:0)

评论中建议的答案有效:

ImageBox.Source = null;