Bonjour,
J'ai un problème de "scope" de binding.
J'ai un objet contenant seulement deux List<string> (ListeNoms et ListeNoms2).
J'ai affecté une instance de cet objet au DataContext de mon UserControl principal dont voici le xaml :
Code xml : 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
20
21 <UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="Test.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <Grid x:Name="LayoutRoot" Background="Black"> <StackPanel> <sdk:AutoCompleteBox ItemsSource="{Binding Path=ListeNoms}" Height="30" /> <ListBox ItemsSource="{Binding Path=ListeNoms2}"> <ListBox.ItemTemplate> <DataTemplate> <sdk:AutoCompleteBox ItemsSource="{Binding Path=ListeNoms}" Text="{Binding}" Height="30" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </StackPanel> </Grid> </UserControl>
Le premier AutoCompleteBox fonctionne bien. Par contre le deuxième qui est dans la ListBox ne fait pas apparaitre les items de ListeNoms2. J'imagine que le datacontext de la ListBox doit masquer la ListeNoms2. Je ne vois pas comment modifier le binding de l'ItemsSource dans mon deuxième AutoCompleteBox pour "remonter" au niveau du datacontext supérieur (je ne sais pas si c'est très clair...)
Si quelqu'un a une idée...
Merci
Partager