bonjour,
j'ai crée une page xaml dans un projet silverlight 4 et j'ai crée un class moncontext puis j'ai bindi ma page xaml avec moncontext ça marche bien.
puis j'ai glaisé un datagrid dans ma page xaml et j le bindi avec une propriété de moncontext et aussi ça marche.
apres j'ai inséré un combobox dans mon datagrid et je veux le bindi avec une autre propriété de moncontext j'ai essayé mais ça marche pas.
voila mon code :
Code xaml : 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
31
32
33 <navigation:Page x:Class="Geolocalisation.Itineraire" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ....... <Grid x:Name="LayoutRoot"> <Grid.RowDefinitions> <RowDefinition Height="327*" /> <RowDefinition Height="153*" /> </Grid.RowDefinitions> ...... <sdk:DataGrid ItemsSource="{Binding ListeInterventionResult, Mode=OneWay}" SelectionMode="Extended" Grid.Row="1" AutoGenerateColumns="False" Height="197" Name="DG_Geoloc" IsReadOnly="False" VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Auto" ColumnWidth="SizeToCells" SelectedItem="" Width="1101"> <sdk:DataGrid.Columns> <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button Content="Affiche" Name="Affiche" Click="Affiche_click"></Button> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox Height="23" Visibility="{Binding ElementName=LayoutRoot, Path=DataContext.Combo}" DropDownClosed="ComboIt_DropDownClosed" Name="ComboIt" Width="80"> </ComboBox> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn> ................ </sdk:DataGrid> </Grid> </navigation:Page>
voila mon context:
Code c# : 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public abstract class moncontext : INotifyPropertyChanged { private Visibility _Combo = Visibility.Collapsed; public Visibility Combo { get { return _Combo; } set { if (_Combo != value) { _Combo = value; NotifyPropertyChanged("Combo"); } } } private ObservableCollection<Geolocalisation.ServiceBD.INTERVENTION> _ListeInterventionResult; public ObservableCollection<Geolocalisation.ServiceBD.INTERVENTION> ListeInterventionResult { get { return _ListeInterventionResult; } set { if (_ListeInterventionResult != value) { _ListeInterventionResult = value; NotifyPropertyChanged("ListeInterventionResult"); } } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } }
Merci d'avance pour vos réponses.
Partager