KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm after some help finding the best way to refer to controls that have been programmtically built in C# If I pre include a label in XAML and name it marketInfo then in code I can set the Tag property with something like marketInfo.Tag = timeNow; However, I'm building controls and assigning each a name using something similar to System.Windows.Controls.Label lbl = new System.Windows.Controls.Label(); lbl.Content = market.name + " - " + DateTime.Now.ToLocalTime().ToLongTimeString(); lbl.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left; lbl.Height = 40; lbl.Name = @"_" + "marketInfo" + countMarket; How do I refer to these controls from another method? I've read a few posts which suggest using the visualtreehelper but this appears to require looping controls to find a particular control. Is there a way to access a control by name to avoid looping? eg something similar to //pseudo code SomeControl("_marketInfo5").Tag = timeNow; Thank you
Tags (comma-separated)
Save Edits
Cancel