I have an WPF ListView with three columns. I see that in my ListView appears an extra empty space(column) on the right handside and I do not know why. How can I remove this extra space using XAML?
<ListView x:Name="MyListView"
Grid.Column="0"
AlternationCount="{Binding pathList.Count}"
ItemsSource="{Binding pathList}"
IsSynchronizedWithCurrentItem="True">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn x:Name="LvItemId"
Header="#"
Width="20"
DisplayMemberBinding="{Binding (ItemsControl.AlternationIndex),
RelativeSource={RelativeSource AncestorType=ListViewItem}}"/>
<GridViewColumn Header="Path"
Width="350"
CellTemplate="{StaticResource NameColumnTemplate}"/>
<GridViewColumn Header="Edit | Delete"
Width="80"
CellTemplate="{StaticResource AddDelItemTemplate}"/>
</GridView>
</ListView.View>
</ListView>
CodePudding user response:
Set the HorizontalAlignment
property of the ListView
to Left
to prevent it from stretching horizontally:
<ListView x:Name="MyListView"
Grid.Column="0"
AlternationCount="{Binding pathList.Count}"
ItemsSource="{Binding pathList}"
IsSynchronizedWithCurrentItem="True"
HorizontalAlignment="Left">
...