0

我试图在单击按钮时弹出图片。

以下代码给出了 System.ArgumentNullException: 'Value cannot be null (Parameter 'baseUri')'

        private async void prettyDialog_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
        {
            Image prettyPicture = new Image();
            BitmapImage prettyBitmap = new BitmapImage();
            prettyPicture.Width = prettyBitmap.DecodePixelWidth = 300;
            prettyBitmap.UriSource = new Uri(prettyPicture.BaseUri, @"c://learncsharp/MonkeyAndRodent.jpeg");
            prettyPicture.Source = prettyBitmap;

            ContentDialog prettyPictureDialog = new ContentDialog()
            {
                Title = "Ain't I pretty",
                CloseButtonText = "boo",
                Content = prettyPicture

            };

            prettyPictureDialog.XamlRoot = this.Content.XamlRoot;
            await prettyPictureDialog.ShowAsync();
        }

有什么建议么?我的编码知识非常有限

4

0 回答 0