Bonjour,
je me perds une peu dans le binding... J'ai créé un projet de test tout simple : une classe Personne (Nom, Prenom, Age) et une window avec 3 textbox bindées aux 3 propriétés.
Ce que j'arrive à faire :
1/ Créer une instance de ma classe Personne en code-behind, et définir également en code-behind la DataContext de ma window => ça marche
2/ Créer une instance de ma classe Personne et définir le DataContext, le tout en Xaml => ça marche
MAIS :
comment récupérer en Xaml, une instance de ma classe Personne créée en code-behind. J'ai défini au niveau de ma window, une variable publique nommée MyPerson = New Personne ("Nom", "Prénom", 30). Comment la référencer au niveau du Xaml pour pouvoir définir le DataContext en Xaml et non pas dans le code-behind ?
Partager