I have a couple of controls that I created in c# -- they are not declared in XAML. I am looking for a way to refer to these controls programatically.
for instance, I create a rectangle and assign a few properties including the name and tag attributes:
Rectangle myRectangle = new Rectangle();
myRectangle.Name = "rec1";
myRectangle.Tag = "tagRec1";
I create several rectangles and want to be able to refer to them later on in code. However, I get an error trying to refer to them as I would an object declared in XAML.
rec1.Opacity for example.
The error is 'the name 'rec1' does not exist in the current context'
How do I refer to these objects once they are created?