Question Add InkCanvas and InkToolbar in WindowsForms

Tobi

New member
Joined
Jul 24, 2021
Messages
3
Programming Experience
3-5
Hi,

I can't get any further. I'm trying to add freehand support to my Windows Forms (NO WPF). I've already felt everything. Before I give up, I wanted to try again here. I copied parts of my code from Microsoft's example for WPF.

Add InkCanvas and InkToolbar:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Ink;
using Windows.Storage.Streams;
using Windows.UI.Input.Inking;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;


namespace Daily_Planner
{
    public partial class Form2 : Form
    {
        private InkCanvas inkCanvas;
        private InkToolbar inktoolbar;
        public Form2()
        {
            InitializeComponent();
            inkCanvas = new InkCanvas();
            //inkCanvas.FocusVisualPrimaryBrush = ImageBrush;
            inktoolbar = new InkToolbar();


            inktoolbar.VerticalAlignment = VerticalAlignment.Top;
            inktoolbar.Margin = new Thickness(10,0,10,0);
            inktoolbar.TargetInkCanvas = inkCanvas;
        }

At first, this is only the part where I wanted to create the objects. However, I already had problems with the assignment of the FocusVisualPrimaryBrush, so I comment on it.

Also, I have the feeling that what I have up to now is not working either. There are no error messages, but I neither see the toolbar nor can I paint anywhere on the InkCanvas.

If someone else knows please no links but a direct explanation, as already mentioned on the Internet I've been everywhere.

Thanks in advance!
 
Where did you add the ink canvas and toolbar to the Controls collection of the form?
 
Back
Top Bottom