Bonjour,
Voici mon code (explication de mon problème est après):
Code : 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
 
<TreeView x:Name="playlist" Grid.Row="1" ItemsSource="{Binding Playlist}">
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding file}">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock x:Name="Name"  Text="{Binding Name}" Margin="0,0,10,0"/>
                        <Button Content="add" Command="{Binding Path=DataContext.Add_file, ElementName=playlist}"
                                CommandParameter="{Binding ElementName=Name, Path=Text}">
                        </Button>
 
                    </StackPanel>
                    <HierarchicalDataTemplate.ItemTemplate>
                        <DataTemplate>
                            <TextBlock x:Name="File_name" Text="{Binding}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="MouseLeftButtonUp">
                                        <i:InvokeCommandAction Command="{Binding Path=DataContext.Current_playlist, ElementName=playlist}"
                                                               CommandParameter="{Binding ElementName=Name,Path=Text}">
 
                                        </i:InvokeCommandAction>
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="MouseLeftButtonUp">
                                        <i:InvokeCommandAction Command="{Binding Path=DataContext.Lecture, ElementName=playlist}"
                                                               CommandParameter="{Binding ElementName=File_name,Path=Text}"></i:InvokeCommandAction>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </TextBlock>
                        </DataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>
Voila mon premier eventtrigger ne marche pas. J'essaye d'envoyer la valeur de mon textblock nommé "Name"(juste au dessus). Cependant il me dit qu'il ne trouve pas ce nom. Donc il m'envoi une chaine vide. J'ai lu qu'il fallait utilisé les relativesource. Mais ça fail lol.

Si vous pouviez m'aider, merci.
Edit: Je sais que le problème viens de:

<TextBlock x:Name="File_name" Text="{Binding}">

Le Binding change le datacontext. Je ne sais pas comment mettre le datacontext du parent.