Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在按钮单击事件中删除 Canvas 上的最后一条绘制线。
this.ContentPanelCanvas.Children.Clear();
上面的线删除画布上的所有绘制线。我只想删除最后一条绘制线。有谁知道我该怎么做?
我还没有测试过,但最后一行可能也是Children集合的最后一个元素。因此,您应该能够:
Children
if (this.ContentPanelCanvas.Children.Count > 0) { this.ContentPanelCanvas.Children.RemoveAt(this.ContentPanelCanvas.Children.Count - 1); }