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 AU ✭✭
    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.