Bonjour,
j'ai créé un UserControl contenant une Listbox chargée d'afficher horizontalement des items. La liste étant longue, si je déplace l'ascenseur et que je sélectionne un item, la liste se replace automatiquement au début et me sélectionne un autre item. J'ai fait une vidéo du problème, ce sera plus simple.
Voici le code de mon UserControl:
Qu'est-ce qui cause ce comportement ?
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
41
42
43
44
45
46
47 <UserControl x:Class="Collectio.ucHorizontalListbox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Collectio" mc:Ignorable="d" d:DesignHeight="163" d:DesignWidth="623"> <UserControl.Resources> <local:CollectionToSingleItem x:Key="CollToItemConverter" /> <local:StringToHyperlink x:Key="StringToLinkConverter" /> </UserControl.Resources> <Grid> <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"> <ListBox MaxHeight="200" Height="Auto" Name="lstPersons" ItemsSource="{Binding}" Background="Transparent" BorderThickness="0,4"> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition Height="83" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Image Width="70" Height="80" Source="{Binding Pictures, Converter={StaticResource CollToItemConverter}}" Stretch="Fill" /> <StackPanel Margin="0,0,10,0" Grid.Row="1"> <TextBlock FontWeight="Bold" TextAlignment="Center" Name="tbName"> <TextBlock.IsEnabled> <MultiBinding Converter="{StaticResource StringToLinkConverter}"> <Binding Path="." /> <Binding Path="." RelativeSource="{RelativeSource Self}"/> </MultiBinding> </TextBlock.IsEnabled> </TextBlock> <TextBlock Text="{Binding Path=Role}" FontStyle="Italic" TextAlignment="Center" TextWrapping="Wrap" Width="80" /> </StackPanel> </Grid> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" Background="Transparent" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> </ScrollViewer> </Grid> </UserControl>
PS: si je clique sur un lien en-dessous d'une photo, la 1ère fois => même comportement que ci-dessus ; la 2e fois => le lien fonctionne normalement...
Partager