Bonjour j'ai ajouter un UserControl au runtime et je ne trouve pas de solution élégante pour le retrouver.
je n'arrive pas à retourver ce control dans un évènement de ma page.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 UCOne UC = new UCOne(); LayoutRoot.Children.Add(UC);
enfin si j'y arrive mais c'est très moche :
est-ce qu'une vrai solution existe ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 private List<string> LayoutElements = new List<string>(); public Page() { InitializeComponent(); UCOne UC = new UCOne(); LayoutRoot.Children.Add(UC); LayoutElements.Add((LayoutRoot.Children.Count-1).ToString()); } void RefindControl() { foreach (string LayoutElement in LayoutElements) { UCOne MesControles = ((UCOne)LayoutRoot.Children[int.Parse(LayoutElement)]); } }
merci d'avance.
Cordialement.
ALCINA
Partager