Bonjour,

J'ai quelques notions en DataBinding sur le WPF, mais quand j'essaye de lier plusieurs ComboBox avec un même DataBinding, je me heurte a quelques problèmes.

Pour résumer, j'ai une liste de clients et je veux afficher leurs informations (numéro, libellé, code postal, ville) via plusieurs ComboBox pour permettre à l'utilisateur de choisir aisément le client. J'arrive sans problèmes à lier les Combos une par une, mais le problème survient quand je veux lier plusieurs Combos au même jeu de données (j'utilise un OleDbDataReader comme jeu de données).

voici mon code :
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
22
23
24
25
26
27
28
29
30
<Window x:Class="Ving.ExportCommandes.Saisies.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    Title="VI-ExportCommandes / Saisie" Height="500" Width="900" Closing="Window_Closing" Loaded="Window_Loaded" WindowState="Maximized" MinHeight="500" MinWidth="900" Icon="/VI-ExportCommandes.Saisies;component/saisie.ico">
	<Window.Resources>
		<BindingGroup x:Key="clients" />
	</Window.Resources>
	<Grid>
		<Label Height="28" Margin="0,62,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="76" Content="Code client" />
		<ComboBox Height="23" Margin="82,62,0,0" Name="txtCodeClient" VerticalAlignment="Top" HorizontalAlignment="Left" Width="110" TabIndex="1" ItemsSource="{Binding Source={StaticResource clients}, Path=numero}" DisplayMemberPath="numero" SelectedValuePath="numero" />
		<Label Height="28" Margin="198,62,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="65" Content="Référence" />
		<TextBox Height="23" Margin="269,62,0,0" Name="txtReference" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120" ToolTip="Ce champ sera automatiquement rempli si vous le laissez vide." TabIndex="2" />
		<Label Margin="395,62,0,0" HorizontalAlignment="Left" Width="44" Content="Nom" Height="28" VerticalAlignment="Top" />
		<ComboBox Height="23" Margin="445,62,222,0" Name="txtNom" VerticalAlignment="Top" TabIndex="3" ItemBindingGroup="{Binding Source={StaticResource clients}}" DisplayMemberPath="libelle" SelectedValuePath="numero" />
		<Label Height="28" Margin="0,62,96,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="120" Content="Date de commande" />
		<WindowsFormsHost Height="28" Margin="0,62,5,0" Name="windowsFormsHostDateCde" VerticalAlignment="Top" HorizontalAlignment="Right" Width="85" TabIndex="6">
			<wf:DateTimePicker Format="Short" />
		</WindowsFormsHost>
 
		<Label Height="28" Margin="290,91,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="28" Content="CP" />
		<ComboBox Height="23" Margin="324,91,0,0" Name="txtCP" VerticalAlignment="Top" HorizontalAlignment="Left" Width="65" ItemBindingGroup="{Binding Source={StaticResource clients}}" DisplayMemberPath="codePostal" SelectedValuePath="numero" TabIndex="4" />
		<Label Height="28" Margin="395,91,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="36" Content="Ville" />
		<ComboBox Height="23" Margin="445,91,222,0" Name="txtVille" VerticalAlignment="Top" IItemBindingGroup="{Binding Source={StaticResource clients}}" DisplayMemberPath="ville" SelectedValuePath="numero" TabIndex="5" />
		<Label Height="28" Margin="0,91,96,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="120" Content="Date de livraison" />
		<WindowsFormsHost Height="28" HorizontalAlignment="Right" Margin="0,91,5,0" Name="windowsFormsHostDateLiv" VerticalAlignment="Top" Width="85" TabIndex="7">
			<wf:DateTimePicker Format="Short" />
		</WindowsFormsHost>
	</Grid>
</Window>

Et le code behind au chargement de la fenêtre :
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
                OleDbCommand lstClients = new OleDbCommand("SELECT * FROM clients", App.mesOptions.bdd);
                OleDbDataReader test = lstClients.ExecuteReader();
                this.Resources["clients"] = test;

Mon problème est que la liaison ne se fait pas du tout, mes Combos restent vides alors que si j'attribue mes ItemBindingGroup en ItemBindingGroup="{Binding}" et que j'affecte chaque Combobox.ItemsSource avec le dataReader, les combos se remplissent correctement.
J'ai également essayé d'attribuer les ItemBindingGroup de cette façon : ItemBindingGroup="{StaticResource clients}"
mais le résultat reste le même.

Quelqu'un sait-il comment je puis faire ?

Merci par avance