Xamarin.forms: WPF: ViewCell content width does not update on ListView width change

Created on 25 Mar 2019  路  1Comment  路  Source: xamarin/Xamarin.Forms

Description

If the ListView width changes on WPF (e.g. on resizing the window), the ViewCell's content is not resized to match the new width. The ViewCell itself seems to resize just fine (based on the hover effect), however the content does not.

Steps to Reproduce

  1. Create a new Xamarin WPF application
  2. Add a ListView as a root of a Page and give it some strings to display
  3. Set an ItemTemplate like such:

    <DataTemplate>
        <ViewCell>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
    
                <Label Grid.Column="0" Text="X" />
    
                <Label
                    Grid.Column="1"
                    HorizontalOptions="Center"
                    Text="{Binding}" />
    
                <Label Grid.Column="2" Text="X" />
            </Grid>
        </ViewCell>
    </DataTemplate>
    
  4. Observe as the Xs (representing the boundaries of the content view) don't behave as expected.

Expected Behavior

The ViewCell's content should resize whenever the ListView's width changes, such that the Xs stay near the window borders.

Actual Behavior

The ViewCell's content does not resize, resulting in the content staying the same size and either being clipped if the window shrinks, or staying centered if the window widens.

Basic Information

  • Version with issue: Latest stable (3.6.0) as well as latest prerelease (4.0.0.250467-pre7)
  • IDE: Visual Studio 15.9.9
  • Platform Target Frameworks:

    • WPF: .NET Framework 4.7.2

Screenshots

Starting point:
image

Widened window:
image

Shrunk window:
image

Reproduction Link

ViewCellResize.WPF.zip

listview 3 help wanted in-progress inactive WPF bug up-for-grabs

Most helpful comment

Added a PR for this if anyone can take a look https://github.com/xamarin/Xamarin.Forms/pull/6179

>All comments

Added a PR for this if anyone can take a look https://github.com/xamarin/Xamarin.Forms/pull/6179

Was this page helpful?
0 / 5 - 0 ratings