I am using Visual Studio Community 2022 64 bit 4.8.04161 on Windows 11 Pro.
I need to be able to draw an image at a particular location. I am attempting to use the documentation at https://learn.microsoft.com/en-us/dotnet/maui/user-interface/graphics/images?view=net-maui-7.0 or https://learn.microsoft.com/en-us/dotnet/maui/user-interface/graphics/images?view=net-maui-6.0 for displaying an IImage
I have created a default .net maui project using visual studio using both 7.0 and 6.0 and then tacked the example code into MainPage::OnCounterClicked. This isn't what I want, of course, but I'm just trying to figure out how to get a clean build.
I have seen the note that PlatformImage is not supported on windows, but not matter what platform I build for, Andriod, iOS, or Windows, I get the error in the title.
Here are the complete errors as reported by the build:
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Platform' does not exist in the namespace 'Microsoft.Maui.Graphics' (are you missing an assembly reference?) GraphicsTest6 (net6.0-windows10.0.19041.0) C:\CleverEggSoftware\trunk\projects\GraphicsTest6\GraphicsTest6\MainPage.xaml.cs 1 Active
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'PlatformImage' does not exist in the current context GraphicsTest6 (net6.0-windows10.0.19041.0) C:\CleverEggSoftware\trunk\projects\GraphicsTest6\GraphicsTest6\MainPage.xaml.cs 31 Active
Here is the hacked class
using Microsoft.Maui.Graphics.Platform;
using System.Reflection;
namespace GraphicsTest6;
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
Microsoft.Maui.Graphics.IImage image;
Assembly assembly = GetType().GetTypeInfo().Assembly;
using (Stream stream = assembly.GetManifestResourceStream(
"GraphicsViewDemos.Resources.Images.dotnet_bot.png"))
{
image = PlatformImage.FromStream(stream);
}
ICanvas canvas = null;
if (image != null) {
canvas.DrawImage(image, 10, 10, image.Width, image.Height);
}
}
}
What am I missing or doing wrong?