How to clear the contents of a canvas in wpf? Tried canvas.clear() doesn't work. Also how can i add zoom control in a wpf application? Zoom with a scroller to move the image.
Any help is greatly appreciated
You want to do MyCanvas.Children.Clear();
Tested with the following code:
<Grid>
<Canvas Name="MyCanvas"/>
<Button Click="Button_Click" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="200" Content="Clear"/>
</Grid>
and
public MainWindow()
{
InitializeComponent();
MyCanvas.Children.Add(new TextBlock() { Text = "Foo" });
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MyCanvas.Children.Clear();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With