[VB.NET][Silverlight]combo et binding dans une grid
Bonjour,
J'ai défini deux combo box, les deux étant bindé de la même manière(binder à une collection coté behind) cependant le combobox(typeclient) dans la datagrid, ne fonctionne pas, (il est vrai que le bind du datagrid se fait via code et donc apres le bind du combox hors datatgrid(combox1)).
Je me demande donc si en fait c'est possible?
Code:
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 31 32 33
| <UserControl x:Class="IHMAdministration.Maintenance" x:Name="control1"
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="399" d:DesignWidth="1500" xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input" BorderBrush="#FF960000" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" >
<Grid x:Name="LayoutRoot" Background="red" Height="399" Width="1500">
<data:DataGrid AutoGenerateColumns="False" Height="255" HorizontalAlignment="Left" Name="DataGrid1" VerticalAlignment="Top" Width="1000">
<data:DataGrid.Columns>
<data:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="IdClient" IsReadOnly="False" Width="Auto" Binding="{Binding IDClient}" />
<data:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Type du client" IsReadOnly="False" Width="Auto">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Name="TypeClient" ItemsSource="{Binding ElementName=control1, Path=DataContext.MyListeTypeClient, BindsDirectlyToSource=False, Mode=TwoWay}" DisplayMemberPath="Libelle" />
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
</data:DataGrid.Columns>
</data:DataGrid>
<TextBox Height="346" HorizontalAlignment="Left" Margin="1029,1,0,0" Name="TxtLicence" VerticalAlignment="Top" Width="440" Text="{Binding ElementName=DataGrid1,Path=SelectedItem.Licence, Mode=TwoWay}" TextWrapping="Wrap" />
<Button Content="Sauvegarde" Height="23" HorizontalAlignment="Left" Margin="1328,364,0,0" Name="btnSave" VerticalAlignment="Top" Width="141" />
<Button Content="ajouter" Height="25" HorizontalAlignment="Left" Margin="867,261,0,0" Name="BtnAdd" VerticalAlignment="Top" Width="133" />
<Button Content="Supprimer" Height="25" HorizontalAlignment="Left" Margin="717,261,0,0" Name="BtnSuppr" VerticalAlignment="Top" Width="144"/>
<ComboBox Height="23" HorizontalAlignment="Left" Margin="1074,136,0,0" Name="ComboBox1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding ElementName=control1, Path=DataContext.MyListeTypeClient}" DisplayMemberPath="Libelle"/>
</Grid>
</UserControl> |
cotebehind dans le constructueur du Usercontrol
Code:
1 2 3 4 5 6 7
|
molist2 = New System.Collections.ObjectModel.ObservableCollection(Of TypeClient2)
molist2.Add(New TypeClient2("grp", "groupement"))
molist2.Add(New TypeClient2("dep", "departement"))
molist2.Add(New TypeClient2("reg", "region"))
molist2.Add(New TypeClient2("com", "commune"))
DataContext = Me |
Puis la property concerné dans la classe
Code:
1 2 3 4 5 6 7 8 9 10 11
|
Public Property MyListeTypeClient As System.Collections.ObjectModel.ObservableCollection(Of TypeClient2)
Get
Return molist2
End Get
Set(ByVal value As System.Collections.ObjectModel.ObservableCollection(Of TypeClient2))
End Set
End Property |
La combo de nom combobox1 contient bien les 4 éléments, mais pas la combo typeclient dans la grid. Quel peut en être la raison
Merci