I want to create shapes on events but don't know how to do it from another class. Can't reach the gr1 grid which is part of MainWindow from Tools class. What is the best solution for this?
Here is my code
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Tools tools = new Tools();
tools.CreateRectangle();
}
}
public class Tools
{
public int Width = 10;
public int Height = 10;
public SolidColorBrush Fill = new SolidColorBrush(Colors.Red);
public void CreateRectangle()
{
Rectangle rectangle01 = new Rectangle();
rectangle01.Width = Width;
rectangle01.Height = Height;
rectangle01.Stroke = Fill;
gr1.Children.Add(rectangle01);
}
}