我正在try 在后面的代码中加载图像.我可以使用XAML成功地将图像加载到Image控件中,但在我的xaml.cs文件中没有显示任何内容.
以下是我的XAML:
<Image Grid.Row="1" Grid.RowSpan="1" Grid.Column="0" x:Name="ImageView1" HorizontalOptions="Start" VerticalOptions="CenterAndExpand" Source="alpha.jpg" />
将加载"Resources/Images/alpha.jpg"中的图像.构建内容为MauiImage.
但以下是mainpage.xaml.cs文件中的代码.
ImageView1.Source = "CWON22.Resources.Images.beta.jpg";
图像控件ImageView1为空.