How to implement multiple InkCanvas with a ListView sharing an InkToolbar?

鲤鱼 秀 65 Reputation points
2023-09-30T14:06:19.3533333+00:00

I urgently need to implement this feature in my program. If you can help me, I will be very grateful!

Developer technologies | Universal Windows Platform (UWP)
Developer technologies | XAML
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-10-02T02:03:16.2266667+00:00

    Hello,

    Welcome to Microsoft Q&A!

    How to implement multiple InkCanvas with a ListView sharing an InkToolbar?

    First of all, it is not supported to share a InkToolbar with multiple InkCanvas at the same time. Please refer to InkToolbar.TargetInkCanvas Property, InkToolbar needs to be associated to a specific InkCanvas. The association is one-to-one.

    If you don't want to create multiple InkToolbars, the only way is to change the TargetInkCanvas of the InkToolbar whenever you want.

    Like this:

       <InkCanvas x:Name="inkCanvasOne" Grid.Column="0" Grid.Row="1" />
       <InkCanvas x:Name="inkCanvasTwo" Grid.Column="1" Grid.Row="1" />
    
       <InkToolbar x:Name="inkToolbar" 
               VerticalAlignment="Top" 
               Margin="10,0,10,0"
                   Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="0"
               TargetInkCanvas="{x:Bind inkCanvasOne}"/>
    
       <Button Content="Click" Click="Button_Click"/>
    
    
      private void Button_Click(object sender, RoutedEventArgs e)
      {
          inkToolbar.TargetInkCanvas = inkCanvasTwo;
      }
    

    Please note that when you change the TargetInkCanvas property to change the associated InkCanva, the changes you've made in the pervious InkCanva with the InkToolbar will still take effect in the pervious InkCanva but new changes made in the current InkCanva won't take effect in the pervious InkCanva.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.