Bonjour,

Nom : Untitled-1.png
Affichages : 244
Taille : 6,9 Ko

J'ai un ListView qui utilise des flèches de direction pour indiquer le tri.
Cela marche très bien..si ce n'est un ptit problème 'esthétique'...comment pourrais-je faire pour que les flèches commencent exactement tout au dessus (et en dessous pour celle du bas), comme cela:
Nom : Untitled-2.png
Affichages : 227
Taille : 1,4 Ko

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
48
49
50
51
52
53
54
<Window x:Class="MainWindow"
    xmlns:local="clr-namespace:WpfApplication1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <DataTemplate x:Key="ArrowUp">
            <Grid>
                <TextBlock VerticalAlignment="Center" Text="{Binding}" />
                <Path VerticalAlignment="Bottom" HorizontalAlignment="Center" Fill="Black" Data="F1 M 3,0L 6,3L 0,3L 3,0 Z " />
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="ArrowDown">
            <Grid>
                <Path VerticalAlignment="Top" HorizontalAlignment="Center" Fill="Black" Data="F1 M 3,3L 0,0L 6,0L 3,3 Z " />
                <TextBlock VerticalAlignment="Center" Text="{Binding}" />
            </Grid>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <ListView Name="PersonListView" GridViewColumnHeader.Click="GridViewColumnHeaderClick">
            <ListView.View>
                <GridView >
                    <GridView.ColumnHeaderContainerStyle>
                        <Style TargetType="{x:Type GridViewColumnHeader}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="GridViewColumnHeader">
                                        <Grid>
                                            <Border Height="25" Name="HeaderBorder" BorderThickness="1" BorderBrush="Black" Background="Gray">
                                                <ContentPresenter Name="HeaderContent" TextElement.Foreground="White" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                            </Border>
                                        </Grid>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsMouseOver" Value="true">
                                                <Setter TargetName="HeaderContent" Property="TextElement.Foreground" Value="White"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GridView.ColumnHeaderContainerStyle>
                    <GridViewColumn DisplayMemberBinding="{Binding Url}" Width="300">
                        <GridViewColumnHeader>Url</GridViewColumnHeader>
                    </GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding Name}" Width="100">
                        <GridViewColumnHeader>Name</GridViewColumnHeader>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</Window>

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Imports System.ComponentModel
 
Class MainWindow
    Private _lastHeaderClicked As GridViewColumnHeader = Nothing
    Private _lastDirection As ListSortDirection = ListSortDirection.Ascending
    Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        Dim personList As New List(Of Person)()
        personList.Add(New Person() With {.Url = "http://www.apple.com", .Name = "Apple"})
        personList.Add(New Person() With {.Url = "http://www.hp.com", .Name = "HP"})
        personList.Add(New Person() With {.Url = "http://www.asus.com", .Name = "Asus"})
        PersonListView.ItemsSource = personList
    End Sub
    Private Sub GridViewColumnHeaderClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Dim headerClicked As GridViewColumnHeader = TryCast(e.OriginalSource, GridViewColumnHeader)
        Dim direction As ListSortDirection
 
        If headerClicked IsNot Nothing Then
            If headerClicked.Role <> GridViewColumnHeaderRole.Padding Then
                If headerClicked IsNot _lastHeaderClicked Then
                    direction = ListSortDirection.Descending
                    If _lastHeaderClicked IsNot Nothing Then
                        _lastHeaderClicked.Column.HeaderTemplate = Nothing
                    End If
                    headerClicked.Column.HeaderTemplate = TryCast(Resources("ArrowDown"), DataTemplate)
                Else
                    If _lastDirection = ListSortDirection.Ascending Then
                        direction = ListSortDirection.Descending
                        headerClicked.Column.HeaderTemplate = TryCast(Resources("ArrowDown"), DataTemplate)
                    Else
                        direction = ListSortDirection.Ascending
                        headerClicked.Column.HeaderTemplate = TryCast(Resources("ArrowUp"), DataTemplate)
                    End If
                End If
                ' 
                _lastHeaderClicked = headerClicked
                _lastDirection = direction
            End If
        End If
    End Sub
End Class
Public Class Person
    Public Property Url() As String
        Get
            Return m_Id
        End Get
        Set(value As String)
            m_Id = value
        End Set
    End Property
    Private m_Id As String
    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Set(value As String)
            m_Name = value
        End Set
    End Property
    Private m_Name As String
End Class
Merci!!