Bonjour à tous,
Je vous expose mon problème concernant le développement d'une application WPF MVVM Surface.
Je me sers d'une ListBox pour afficher des icone sur un plan.
J'aimerai changer cette icone quand il passe en SelectedItem (Image entre les balises DataTemplate).
Voici la partie de mon code qui gère ma listbox:
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
34
35
36
37
38
39
40 <s:ScatterViewItem Width="500" Height="500" Center="700,540" Orientation="0" CanMove="False" CanRotate="True" HorizontalAlignment="Center" VerticalAlignment="Center" > <s:ScatterViewItem.Background> <ImageBrush ImageSource="{Binding ImagePlan}" Stretch="Fill"/> </s:ScatterViewItem.Background> <ListBox Background="{x:Null}" Width="500" Height="500" ItemsSource="{Binding Media}" SelectedItem="{Binding SelectedMedia}" Margin="0"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <Canvas> </Canvas> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <Image Width="32" Height="32" Source="C:\Users\Dago\Documents\Visual Studio 2010\Projects\AppPalaisRois\AppPhototheque\Resources\Camino_icon.png" /> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="Canvas.Top" Value="{Binding Y}" /> <Setter Property="Canvas.Left" Value="{Binding X}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <TextBlock Name="TheBGControl"> <ContentPresenter /> </TextBlock> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="{x:Null}" TargetName="TheBGControl" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ListBox.ItemContainerStyle> </ListBox> </s:ScatterViewItem>
Partager