WPF ListView Star Field Size ("*")
I would like to fill the rest of the WPF area with a ListView
specific column.
I searched search terms and found the following solution:
<GridViewColumn Header="Error" DisplayMemberBinding="{Binding ErrorDescription}"
Width="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ListView}}, Converter={StaticResource WidtConvert}} />
And the converter:
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
ListView l = value as ListView;
GridView g = l.View as GridView;
double total = 0;
for (int i = 0; i < g.Columns.Count - 1; i++)
{
total += g.Columns[i].ActualWidth;
}
return (l.ActualWidth - total);
}
But the problem is that during the call to the converter, all columns, including ListView.ActualWidth
, are 0.
I don't want to use any code like for Listview_SizeChanged
etc.
+3
source to share