I have created a new "Windows Forms App":
Now I install the Microsoft.Toolkit.Forms.UI.Controls from NuGet.
It requires these dependencies:
After clicking "I accept", the next thing that happens is that an error message "Failed to lauch the design tools server process." is shown:
I select the Form1 designer in the tabs, and the ToolBox now shows the new tools:
However, the designer is gone, and when I try to bring it up again, the message "This item does not support previewing." appears each time I click Form1.vb -> View Designer:
I have repeated the process several times.
When I switch from Debug x86 to Debug AnyCPU, I can open up the designer again.
However, when I then try to drag one of the tools onto the form, an error occurs:
"Failed to create component 'InkCanvas'. The error message follows: 'Microsoft.DotnetNet.DesignTools.Client.DesignToolsServerException: Could not find Windows Runtime type 'Microsoft.Toolkit.Win32.UI.XamlHost.IXamlMetadataContainer'.
I am stuck.
CodePudding user response:
It works if I instantiate the control by code instead of dragging it from the ToolBox.
So perhaps a compatiblity problem with WinForms designer?
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim f As New Microsoft.Toolkit.Forms.UI.Controls.InkCanvas
With f
.Size = New Size(400, 100)
.Location = New Point(20, 20)
End With
AddHandler f.TextChanged, AddressOf Ink_Changed
Me.Controls.Add(f)
End Sub
Friend Sub Ink_Changed(sender As Object, e As EventArgs)
'Write code here.
End Sub
End Class