Back to Browse

WPF C# Tutorial - Dynamically add and remove items from canvas in visual studio

33.3K views
Jun 10, 2020
9:21

Source code - https://www.mooict.com/wpf-c-tutorial-add-and-remove-objects-with-mouse-click-in-visual-studio/ Hi welcome to another fun tutorial from moo ict. in this tutorial I will show you how to add and remove rectangles dynamically from a canvas using wpf and c#. We will be using lots of rectangles to make fun games very soon so its important to understand the attributes of them inside of the canvas element. we will be linking a mouse event directly to the canvas then use c# to find if we have clicked on a empty spot inside of the canvas or have we clicked on a existing rectangle. if we clicked on a rectangle then we will remove it and if not we will spawn a rectangle on the canvas with few extra bonus such as giving it a random colour and a border. this was a fun tutorial to make and again this is a quick tutorial that you can use just to the hang of it before we move into making games. Hope you enjoy it and happy programming.

Download

0 formats

No download links available.

WPF C# Tutorial - Dynamically add and remove items from canvas in visual studio | NatokHD