Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stretch content horizontally in ListViewItem #3914

Merged
merged 1 commit into from
Jan 11, 2021
Merged

Stretch content horizontally in ListViewItem #3914

merged 1 commit into from
Jan 11, 2021

Conversation

robloo
Copy link
Contributor

@robloo robloo commented Jan 9, 2021

Description

Content in ListViewItem is not horizontally stretched by default. Instead, the content is left aligned. This makes content appear as shown in the top image instead of the expected bottom image below (taken from #1402)

This PR changes the horizontal alignment to Stretch from Left. Risks of this change should be quite low since it's only changing the container style (ListViewItem itself) #1402 (comment)

The original behavior (Left alignment) is different from older XAML technologies such as WPF and is counterintuitive for application developers. It prevents doing something such as what is below unless the ItemContainerStyle is overridden:

<ListView>
  <ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
    </Style>
  </ListView.ItemContainerStyle>
</ListView>

The reasons for switching may have been due to the prevalence of horizontal scrolling in ListViews when UWP/Metro styling first came around.

Motivation and Context

Closes #1402
Closes #3682

How Has This Been Tested?

Screenshots (if appropriate):

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jan 9, 2021
@robloo
Copy link
Contributor Author

robloo commented Jan 9, 2021

An open question is whether ListPickerFlyoutPresenterItemStyle should be updated as well.

@ranjeshj
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ranjeshj ranjeshj added area-Styling team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Jan 11, 2021
@mdtauk
Copy link
Contributor

mdtauk commented Jan 11, 2021

Is there any consideration needed for other list views, like GridView or SemanticZoom controls?

@ranjeshj ranjeshj merged commit 2143a5f into microsoft:master Jan 11, 2021
@ranjeshj
Copy link
Contributor

An open question is whether ListPickerFlyoutPresenterItemStyle should be updated as well.

Interesting. I don't see this style being used anywhere. @YuliKl do you know where this style is used ?

@ranjeshj
Copy link
Contributor

Is there any consideration needed for other list views, like GridView or SemanticZoom controls?

I don't think this is very interesting for GridView. SemanticZoom just uses ListView/GridView inside them.

@robloo robloo deleted the robloo/listviewitem-stretch branch January 11, 2021 20:10
Kinnara added a commit to Kinnara/ModernWpf that referenced this pull request Jul 9, 2022
Kinnara added a commit to Kinnara/ModernWpf that referenced this pull request Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Styling team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grid Star-Sizing does not work inside ListView Proposal: Make ListViewItem stretch by default
3 participants