J'ai lié deux contrôles de zone de liste à un fichier xml (c'est-à-dire une zone de liste liée au xml et l'autre liée à la première zone de liste). Les zones de liste affichent les valeurs de noeud dans le fichier XML à la suite de la liaison. Les opérations Add, Edit et Delete peuvent être effectuées et persistent dans le fichier source, mais la cible n'est pas mise à jour à moins que la fenêtre ne soit fermée puis rouverte. Le code pour la première zone de liste est la suivante:Cible liée non mise à jour
<ListBox Name="listBox1" Width="224" Height="115" Margin="0,0,0,5"
IsSynchronizedWithCurrentItem="False" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Style="{StaticResource ListBoxStyle1}"
ItemsSource="{Binding Source={StaticResource RecipeList}, XPath=recipeType,
Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Background="Black">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="170"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="1" Height="35" Background="#181818">
<TextBlock Background="Black" Margin="1" FontWeight="Bold"
Padding="7" Height="33" Width="184" Foreground="#D0D0D0">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}">
<Binding XPath="@description" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
et pour la deuxième zone de liste:
<ListBox Name="listBox2" Width="218" Height="144" Margin="0,0,0,5"
IsSynchronizedWithCurrentItem="True" Style="{StaticResource ListBoxStyle1}"
ItemsSource="{Binding ElementName=listBox1, Path=SelectedItem, Mode=OneWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Height="auto" Background="#181818">
<TextBlock Padding="7">
<StackPanel Background="Black" Margin="-5.5,-5.5,-6,-6.8">
<TextBlock Width="210" FontWeight="Bold" FontSize="12"
HorizontalAlignment="Left" Text="{Binding XPath=name}"
Background="Black" Foreground="#D0D0D0" Padding="0" Margin="5,0,0,3" />
<TextBlock Width="187" FontSize="11" HorizontalAlignment="Left"
Text="{Binding XPath=summary}" Background="Black" Foreground="Gray"
Margin="5,0,0,5" />
</StackPanel>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Ma question est de savoir comment mettre à jour la cible ou rafraîchir/recharger la fenêtre dans ce cas.
Merci de votre participation.
Par cible, voulez-vous dire _listBox2_. – publicgk