简体   繁体   中英

Clear image from windows store app

I'm inserting an image to my windows store app by function:

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;
            }            
        }
    }

I want to have a method that will clear the image from my ImageBox . Doing some research on Google I found to use:

ImageBox.Image = false;

There is no *.image property in my ImageBox , how else I can implement that?

评论中建议的答案有效:

ImageBox.Source = null;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM