WPF header not working as I would like them to

Iam new to wpf and am struggling to position my headers probably, All the data is going into each header but I want it so that the data is one per header.(I looked all over google and cant find a solution idk even if using headers is the right thing to do even)


I am sorry. I do not understand. What headers? What do you mean by headers? What data?

see in the second screenshot(above last post) I have position and Team in the main list-view but all the columns are getting group with each header(position,team). I want it where only one column is with one header.

Here is a mock up in excel, See on the left is whats happening to my headers where all the data is getting put under one header then the next header the information is repeated, on the right is what iam looking for where one header is for one column.

I know I explain that not the best but thats the only way i can think of that makes sense


I suggest not using ListView. It is old, inflexible and confusing to use.

Use DataGrid instead. You do not show much of your code so I am not sure how to provide a sample that is more relevant than the following but hopefully it is enough. You can set the ItemsSource in code as in the following:

TeamGrid.ItemsSource = Teams;

Then the following is some sample XAML.

<DataGrid x:Name="TeamGrid" AutoGenerateColumns="False">
        <DataGridTextColumn Header="Pos"  Binding="{Binding Pos}"/>
        <DataGridTextColumn Header="Team"  Binding="{Binding Team}"/>
        <DataGridTextColumn Header="Data"  Binding="{Binding Data}"/>

The following is my class for the data:

public class classTeam
    public int Pos { get; set; }
    public string Team { get; set; }
    public string Data { get; set; }
1 Like

Got it working thanks for your help. Ya the Listview was hard to use and iam finding using a datagrid is way better.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.