Forum Libraries, Components, and Plugins
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Xamarin Forms SKCanvasView

DaveAuDaveAu AUMember ✭✭

So from my basic understanding I have created an SKCanvasView and gets the finger painting working like in all the samples...etc. Just trying to find what is the way to clear my SKCanvasView? Does anyone have an example? I'd just like to have a button to clear the canvas. Or point me in the right direction

   <Grid>
<Grid x:Name="CanvasGrid">
    <forms:SKCanvasView x:Name="CanvasView" PaintSurface="PaintSurface"/>
</Grid>
    <Grid.Effects>
    <helpers:TouchEffect Capture="True" TouchAction="OnTouchEffectAction"/>
    </GridEffects>
   </Grid>
   <Button Text="Clear" Clicked="ClearCanvas"/>

THanks.

Best Answer

  • DaveAuDaveAu AUMember ✭✭
    Accepted Answer

    I'm doing some hacky thing in the code behind attached to a button:

    CanvasGrid.Children.Clear();
    CanvasGrid.Children.Add(CanvasView);
    
    completedPaths.Clear();
    

    Is there a better way to do this. Thanks.

Answers

  • DaveAuDaveAu AUMember ✭✭
    Accepted Answer

    I'm doing some hacky thing in the code behind attached to a button:

    CanvasGrid.Children.Clear();
    CanvasGrid.Children.Add(CanvasView);
    
    completedPaths.Clear();
    

    Is there a better way to do this. Thanks.

  • DJNovaDJNova USMember ✭✭

    in your "PaintSurface" handler get a reference to the canvas and then use canvas.Clear(SKColors.White);

Sign In or Register to comment.