[英]How to clear the contents of a canvas in wpf?
How to clear the contents of a canvas in wpf? 如何在wpf中清除画布的内容? Tried canvas.clear() doesn't work. 尝试canvas.clear()不起作用。 Also how can i add zoom control in a wpf application? 另外如何在wpf应用程序中添加缩放控件? Zoom with a scroller to move the image. 使用滚动条缩放以移动图像。
Any help is greatly appreciated 任何帮助是极大的赞赏
You want to do MyCanvas.Children.Clear();
你想做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();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.