win2d

Why does visual studio think canvas control isn't a part of the win2d library?


I'm following the win2d tutorial here, but instead of creating a blank app I did a WPF C# application. No matter what I try, visual studio says the namespace doesn't have canvas control in it. I checked if the tutorial was up to date and it was, is something in my code stopping the library from working?

My code is here:

`<Window x:Class="WpfAppTest1Sidescroller.MainWindow"
        xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfAppTest1Sidescroller"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <canvas:CanvasControl Draw="CanvasControl_Draw" ClearColor="CornflowerBlue"/>
    </Grid>
</Window>`

I tried rechecking the statement that introduces the canvas to see if I typed it wrong, but it looks like I didn't. I can't find anything about this happening or how to fix it on google, so I'm going here. I just installed visual studio a few days ago and I don't have that many optional addons, so that might have something to do with it.


Solution

  • I don't think you can use win2d in a WPF project. But WPF has great graphics on its own. Look here: WPF Graphics Rendering Overview

    Win2d is used in UWP / WinUI projects.