Bonjour j'ai ajouter un UserControl au runtime et je ne trouve pas de solution élégante pour le retrouver.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
UCOne UC = new UCOne();
LayoutRoot.Children.Add(UC);
je n'arrive pas à retourver ce control dans un évènement de ma page.

enfin si j'y arrive mais c'est très moche :
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)]);
}
}
est-ce qu'une vrai solution existe ?

merci d'avance.
Cordialement.
ALCINA