IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Développement Windows Discussion :

WPF - affichage de plusieurs colonnes dans un treeview ?


Sujet :

Développement Windows

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    76
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 76
    Par défaut WPF - affichage de plusieurs colonnes dans un treeview ?
    Bonjour à tous,

    Je bloque en ce moment face à un problem d'affichage.

    Je souhaite faire ceci, mais je n'arrive pas à supprimer les petites fleches (en jaune) des colonnes autres que le première (Label).
    Auriez vous une idée ?

    Merci d'avance

    Nom : Capture.JPG
Affichages : 436
Taille : 22,6 Ko

    XAML:
    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
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    <Window x:Class="RelateONUtoOtherLU.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Relate ONU to other LU" Height="600" Width="1200" Name="UI">
        <Grid DataContext="{Binding ElementName=UI}">
            <Label Content="Building address" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
            <Label Content="Building address" HorizontalAlignment="Left" Margin="595.655,10,0,0" VerticalAlignment="Top"/>
            <ComboBox x:Name="cbBuildingAddressONU" HorizontalAlignment="Left" Margin="112.477,13.804,0,0" VerticalAlignment="Top" Width="475"/>
            <ComboBox x:Name="cbBuildingAddressLU" HorizontalAlignment="Left" Margin="701.305,13.804,0,0" VerticalAlignment="Top" Width="475"/>
     
            <ListView ItemsSource="{Binding ONUs}" x:Name="tvONU" HorizontalAlignment="Left" Height="506" Margin="10,53.891,0,0" VerticalAlignment="Top" Width="580" >
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Label">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TreeView BorderThickness="0" ItemsSource="{Binding ONUs}" >
                                            <TreeView.ItemTemplate>
                                                <HierarchicalDataTemplate ItemsSource="{Binding ONUs}">
                                                    <TextBlock Text="{Binding Label}" TextAlignment="Right" />
                                                </HierarchicalDataTemplate>
                                            </TreeView.ItemTemplate>
                                        </TreeView>
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="CID">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TreeView BorderThickness="0" ItemsSource="{Binding ONUs}" >
                                            <TreeView.ItemTemplate>
                                                <HierarchicalDataTemplate ItemsSource="{Binding ONUs}">
                                                    <TextBlock Text="{Binding CID}" TextAlignment="Right" />
                                                </HierarchicalDataTemplate>
                                            </TreeView.ItemTemplate>
                                        </TreeView>
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Nature">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TreeView BorderThickness="0" ItemsSource="{Binding ONUs}" >
                                            <TreeView.ItemTemplate>
                                                <HierarchicalDataTemplate ItemsSource="{Binding ONUs}">
                                                    <TextBlock Text="{Binding Nature}" TextAlignment="Right" />
                                                </HierarchicalDataTemplate>
                                            </TreeView.ItemTemplate>
                                        </TreeView>
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Post Box">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TreeView BorderThickness="0" ItemsSource="{Binding ONUs}" >
                                            <TreeView.ItemTemplate>
                                                <HierarchicalDataTemplate ItemsSource="{Binding ONUs}">
                                                    <TextBlock Text="{Binding PostBox}" TextAlignment="Right" />
                                                </HierarchicalDataTemplate>
                                            </TreeView.ItemTemplate>
                                        </TreeView>
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Block">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TreeView BorderThickness="0" ItemsSource="{Binding ONUs}" >
                                            <TreeView.ItemTemplate>
                                                <HierarchicalDataTemplate ItemsSource="{Binding ONUs}">
                                                    <TextBlock Text="{Binding Block}" TextAlignment="Right" />
                                                </HierarchicalDataTemplate>
                                            </TreeView.ItemTemplate>
                                        </TreeView>
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Floor">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TreeView BorderThickness="0" ItemsSource="{Binding ONUs}" >
                                            <TreeView.ItemTemplate>
                                                <HierarchicalDataTemplate ItemsSource="{Binding ONUs}">
                                                    <TextBlock Text="{Binding Floor}" TextAlignment="Right" />
                                                </HierarchicalDataTemplate>
                                            </TreeView.ItemTemplate>
                                        </TreeView>
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Apartment">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TreeView BorderThickness="0" ItemsSource="{Binding ONUs}" >
                                            <TreeView.ItemTemplate>
                                                <HierarchicalDataTemplate ItemsSource="{Binding ONUs}">
                                                    <TextBlock Text="{Binding Apartment}" TextAlignment="Right" />
                                                </HierarchicalDataTemplate>
                                            </TreeView.ItemTemplate>
                                        </TreeView>
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="CAD details">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TreeView BorderThickness="0" ItemsSource="{Binding ONUs}" >
                                            <TreeView.ItemTemplate>
                                                <HierarchicalDataTemplate ItemsSource="{Binding ONUs}">
                                                    <TextBlock Text="{Binding CADdetails}" TextAlignment="Right" />
                                                </HierarchicalDataTemplate>
                                            </TreeView.ItemTemplate>
                                        </TreeView>
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="VerticalContentAlignment" Value="Top" />
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
     
            <!--<TreeView x:Name="tvLU" HorizontalAlignment="Left" Height="506" Margin="495.66,53.891,0,0" VerticalAlignment="Top" Width="480"/>-->
     
        </Grid>
    </Window>
    C#
    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
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
     
    namespace RelateONUtoOtherLU
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            private ObservableCollection<ONU_LUDetails> _processes = new ObservableCollection<ONU_LUDetails>();
     
            public MainWindow()
            {
                InitializeComponent();
     
                //ONU 1
                ONUs.Add(new ONU_LUDetails
                {
                    CID = "1",
                    Nature = "LU",
                    PostBox = "",
                    Block = "",
                    Floor = "",
                    Apartment = "",
                    CADdetails = "#A1/C/C17",
                    ONUs = new ObservableCollection<UNI_LUDetails>()
                });
                var onu1 = new UNI_LUDetails { Label = "ONU - 14-1", ONUs = new ObservableCollection<UNI_LUDetails>() };
                ONUs[0].ONUs.Add(onu1);
     
                //ONU 2
                ONUs.Add(new ONU_LUDetails
                {
                    CID = "1",
                    Nature = "LU",
                    PostBox = "",
                    Block = "",
                    Floor = "",
                    Apartment = "",
                    CADdetails = "#A4/C/C14",
                    ONUs = new ObservableCollection<UNI_LUDetails>()
                });
                var onu2 = new UNI_LUDetails { Label = "ONU - 16-1", ONUs = new ObservableCollection<UNI_LUDetails>() };
                ONUs[1].ONUs.Add(onu2);
     
                //ONU 3
                ONUs.Add(new ONU_LUDetails
                {
                    ONUs = new ObservableCollection<UNI_LUDetails>()
                });
                var onu3 = new UNI_LUDetails { Label = "ONU - 18-1", ONUs = new ObservableCollection<UNI_LUDetails>() };
                onu3.ONUs.Add(new UNI_LUDetails { Label = "UNI 1", CID = "1", Nature = "LU", PostBox = "101", Block = "", Floor = "1", Apartment = "101", CADdetails = "#BLA.A1/LB/S9", ONUs = new ObservableCollection<UNI_LUDetails>() });
                onu3.ONUs.Add(new UNI_LUDetails { Label = "UNI 2", CID = "2", Nature = "LU", PostBox = "102", Block = "", Floor = "1", Apartment = "102", CADdetails = "#BLA.A1/LC/", ONUs = new ObservableCollection<UNI_LUDetails>() });
                onu3.ONUs.Add(new UNI_LUDetails { Label = "UNI 3", CID = "3", Nature = "LU", PostBox = "103", Block = "", Floor = "1", Apartment = "103", CADdetails = "#BLA.A1/LD/S32", ONUs = new ObservableCollection<UNI_LUDetails>() });
                onu3.ONUs.Add(new UNI_LUDetails { Label = "UNI 4", CID = "4", Nature = "LU", PostBox = "104", Block = "", Floor = "1", Apartment = "104", CADdetails = "#BLA.A10/LA/S8", ONUs = new ObservableCollection<UNI_LUDetails>() });
                ONUs[2].ONUs.Add(onu3);
            }
     
            public ObservableCollection<ONU_LUDetails> ONUs
            {
                get { return _processes; }
                set { _processes = value; }
            }
        }
     
        public class ONU_LUDetails
        {
            public ObservableCollection<UNI_LUDetails> ONUs { get; set; }
            public string Label { get; set; }
            public string CID { get; set; }
            public string Nature { get; set; }
            public string PostBox { get; set; }
            public string Block { get; set; }
            public string Floor { get; set; }
            public string Apartment { get; set; }
            public string CADdetails { get; set; }
        }
     
        public class UNI_LUDetails
        {
            public ObservableCollection<UNI_LUDetails> ONUs { get; set; }
            public string Label { get; set; }
            public string CID { get; set; }
            public string Nature { get; set; }
            public string PostBox { get; set; }
            public string Block { get; set; }
            public string Floor { get; set; }
            public string Apartment { get; set; }
            public string CADdetails { get; set; }
        }
    }

  2. #2
    Membre Expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Par défaut
    Tu dois modifier le template des treeviews pour lesquelles tu ne veux pas de flèche.

    Il y a un exemple de template ici : http://stackoverflow.com/questions/1...and-icon-arrow

Discussions similaires

  1. Propriete d'affichage d'une colonne dans Access
    Par ager1912 dans le forum Accès aux données
    Réponses: 1
    Dernier message: 23/10/2006, 19h36
  2. Affichage de plusieurs images dans dans un Timage
    Par Petzouille57 dans le forum Delphi
    Réponses: 1
    Dernier message: 19/10/2006, 16h16
  3. Plusieurs colonnes dans CListBox
    Par lio33 dans le forum MFC
    Réponses: 4
    Dernier message: 26/04/2006, 11h14
  4. Lister sur plusieurs colonnes dans état
    Par armagued dans le forum Access
    Réponses: 3
    Dernier message: 30/10/2005, 21h21
  5. Des colonnes dans un Treeview
    Par mr_langelot dans le forum Composants VCL
    Réponses: 6
    Dernier message: 28/07/2004, 09h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo