Bonjour à tous,
Pour le contexte, j'ai une Datagrid de "Mission" avec un statut : Ferme (booléen)
J'ai une Datagrid possédant un Trigger pour pouvoir gérer l'évènement de sélection de ligne.
J'ai également, sur certaines lignes de cette Datagrid, des HyperlinkButton pour modifier le statut d'une mission. Le bouton apparaît lorsque le statut est à faux.
Dans la View :
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44 <sdk:DataGrid x:Name="DataGridMission" ItemsSource="{Binding Path=DataGridMission, Mode=TwoWay}" IsReadOnly="True" AutoGenerateColumns="False" ColumnWidth="SizeToCells" SelectedIndex="{Binding Path=SelectedIndex, Mode= TwoWay}" > <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <cmd:EventToCommand Command="{Binding SelectionnerCommand}" CommandParameter="{Binding SelectedItems, ElementName=DataGridMission, Mode=TwoWay}" /> </i:EventTrigger> </i:Interaction.Triggers> <sdk:DataGrid.Columns> <sdk:DataGridTextColumn x:Name="ClientCol" Binding="{Binding Path=Client}" Header="Client" /> <sdk:DataGridTextColumn x:Name="DateDebutCol" Binding="{Binding Path=DateDebut}" Header="Début" /> <sdk:DataGridTextColumn x:Name="DateFinCol" Binding="{Binding Path=DateFin}" Header="Fin" /> <sdk:DataGridTextColumn x:Name="RessourceCol" Binding="{Binding Path=Ressource}" Header="Ressource" /> <sdk:DataGridTextColumn x:Name="FermeCol" Binding="{Binding Path=Ferme}" Header="Ferme" Width="SizeToHeader"/> <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <HyperlinkButton Visibility="Visible" x:Name="Ferme" IsEnabled="{Binding Path=EnableFerme}" Opacity="{Binding Path=OpacityFerme}" Height="20" Width="20" Command="{Binding Path=FermeCommand}"> <HyperlinkButton.Background> <ImageBrush ImageSource="/TAF.View;component/Assets/Images/zoom.png" Stretch="Fill" /> </HyperlinkButton.Background> </HyperlinkButton> </StackPanel> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> </sdk:DataGrid.Columns> </sdk:DataGrid>
Dans la ViewModel :
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 public ICommand OKCommand { get; internal set; } public ICommand FermeCommand { get; internal set; } public ICommand SelectionnerCommand { get; set; } private void InitCommandes() { OKCommand = new RelayCommand(() => OkCommandAction()); FermeCommand = new RelayCommand(() => FermeCommandAction()); SelectionnerCommand = new RelayCommand<IList>((IList items) => Selectionner_Action(items)); } private void FermeCommandAction() { MessageBox.Show("test"); } private void Selectionner_Action(IList Items) { IEnumerator ilm = Items.GetEnumerator(); if (ilm.MoveNext()) SelectedMission = ilm.Current as RechercheMissionPerso; else SelectedMission = null; if (SelectedMission != null) { //envoi vers la page correspondante } } }
Maintenant, le problème qui se pose est que lorsque je veux cliquer sur le bouton pour changer le statut d'une mission, l'évènement de sélection de la ligne se fait avant. Je ne peux jamais cliquer sur le bouton.
Je ne sais pas quoi faire pour régler ce problème...
J'aimerai pourvoir faire quelque chose comme : Si je clique sur le bouton, alors on fait pas l'évènement de la sélection de ligne. Ou alors est-il possible d'avoir une propriété que je pourrais binder pour savoir si le bouton a été cliqué ou non ?
Merci à ceux qui peuvent m'aider !![]()
Partager