Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF listview remove extra column generated

Tags:

listview

wpf

When I use a ListView in WPF it always generates one extra column at the end of the ListView. For example, if I define two columns in my listview and when I run it it generates those two columns plus one empty column header. Any idea how I can remove that?

Sample ListView XAML

<ListView ItemsSource="{Binding Path=SearchAttributes}"
                      DockPanel.Dock="Top">
                <ListView.View>
                    <GridView x:Name="grdView">
                        <GridViewColumn Header="Name" DisplayMemberBinding="{Binding SearchFieldName}" />
                        <GridViewColumn Header="Balance" Width="Auto"
                                        CellTemplateSelector="{StaticResource searchFilterDataTemplateSelector}"
                                        >
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>

Thanks, Jithu

like image 610
Jithu Avatar asked Nov 26 '22 17:11

Jithu


1 Answers

The last column is simply the left over space you need to size the columns to fit exactly in the space. By defining the width as Auto you are making sure that is only as big as possible.

like image 65
Joe Sonderegger Avatar answered Nov 29 '22 05:11

Joe Sonderegger