Panels contain elements that are typically added in XAML as a base for the user interface. Sometimes, however, we need to add or remove elements dynamically at run time based on user actions or other criteria. Let's see how this can be done.
Make sure Visual Studio is up and running.
We'll create a simple circle drawing program. Every click adds a circle to a
MainWindow.xaml. Replace the default
Canvas, name it
_canvas, and set its
MouseUpevent to the
<Canvas x:Name="_canvas" Background="White" MouseUp="OnClickCanvas"> </Canvas>