mooict / WPF-Add-or-Remove-objects-dynamically-from-Canvas

In this project I will demonstrate how to add or remove items from the Canvas dynamically using C# and WPF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Video Tutorial -

Written Tutorial -

https://www.mooict.com/wpf-c-tutorial-add-and-remove-objects-with-mouse-click-in-visual-studio/

About

In this project I will demonstrate how to add or remove items from the Canvas dynamically using C# and WPF

License:Apache License 2.0


Languages

Language:C# 100.0%