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

[Android] StackPanel does not use the return of child Arrange causing aligment issues #3347

Open
2 of 8 tasks
dr1rrb opened this issue Jun 10, 2020 · 4 comments
Open
2 of 8 tasks
Labels
difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..)

Comments

@dr1rrb
Copy link
Member

dr1rrb commented Jun 10, 2020

Current behavior

With the visual tree:

<Setter Property="ItemsPanel">
    <Setter.Value>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal" Background="Red"></StackPanel>
        </ItemsPanelTemplate>
    </Setter.Value>
</Setter>


<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="local:ChartLegend">
            <Border
                  BorderBrush="Black"
                  BorderThickness="5"
                  CornerRadius="{TemplateBinding CornerRadius}"
                  Padding="{TemplateBinding Padding}"
                  Background="Green" x:Name="SOI">
                <StackPanel Orientation="Vertical" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                    <ContentControl Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/>
                    <ItemsPresenter/>
                </StackPanel>
            </Border>
        </ControlTemplate>
    </Setter.Value>
</Setter>

The ContentPresenter.Content has the width of the parent (a Canvas) and is not aligned properly.

image

Expected behavior

image

How to reproduce it (as minimally and precisely as possible)

cf. issue (private) linked below

==> Another repro which might be easier to investigate: #3755

Workaround

Manually align (usually Left) the control.

Environment

Nuget Package: Uno.UI
Package Version(s): 3.0
Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Windows
  • Build tasks
  • Solution Templates

Visual Studio: irrelevant
Relevant plugins: none

Anything else we need to know?

This might have been fixed by https://github.com/unoplatform/uno/commits/dev/cdb/bugs/layout-bugs-big-refactoring (@carldebilly )

@dr1rrb dr1rrb added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jun 10, 2020
@francoistanguay francoistanguay added this to the 3.1 milestone Aug 29, 2020
@francoistanguay francoistanguay removed the triage/untriaged Indicates an issue requires triaging or verification label Aug 29, 2020
@dr1rrb dr1rrb changed the title Possible invalid layout when [Android] StackPanel does not use the return of child Arrange causing aligment issues Aug 31, 2020
@carldebilly carldebilly modified the milestones: 3.1, HighPriority, HotFixes Aug 31, 2020
@carldebilly carldebilly removed this from the 3.1 milestone Sep 14, 2020
@agneszitte agneszitte added the project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..) label Sep 21, 2020
@jeromelaban jeromelaban added the difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. label Feb 15, 2021
@MartinZikmund MartinZikmund added difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI area/eu and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jun 1, 2021
@MartinZikmund MartinZikmund changed the title [Android] StackPanel does not use the return of child Arrange causing aligment issues [Android] StackPanel does not use the return of child Arrange causing aligment issues Jun 12, 2023
@MartinZikmund MartinZikmund added the triage/potentially-fixed Categorizes an issue as potentially fixed by some unlinked PR, fix needs to be verified label Jun 12, 2023
@Youssef1313 Youssef1313 self-assigned this Sep 18, 2023
@Youssef1313 Youssef1313 added the platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform label Sep 18, 2023
@ramezgerges ramezgerges removed the triage/potentially-fixed Categorizes an issue as potentially fixed by some unlinked PR, fix needs to be verified label Sep 18, 2023
@Youssef1313 Youssef1313 removed their assignment Sep 18, 2023
@ramezgerges ramezgerges self-assigned this Sep 18, 2023
@ramezgerges
Copy link
Contributor

A more minimal repro is

	<StackPanel x:Name="sp1">
	    <ContentControl x:Name="cc">
	        <StackPanel Width="240" x:Name="sp2">
	            <TextBox x:Name="tb" Text="textbox1" />
	        </StackPanel>
	    </ContentControl>
	</StackPanel>

The problem is not with StackPanel, but with ContentControl. On Android (and iOS, but I didn't test), we don't follow the WinUI template for ContentControl, which specifies Top and Left alignments for the inner ContentPresenter (by a TemplateBinding). Matching the template fixes the issues, but we left it that way as it caused other issues, so I guess this is blocked for now.

@Youssef1313
Copy link
Member

I have #13069 but wasn't able to complete it.

@ramezgerges ramezgerges removed their assignment Oct 5, 2023
@Youssef1313
Copy link
Member

This will likely be fixed by #18261

@carldebilly
Copy link
Member

This will likely be fixed by #18261

Old bug finally fixed :-) Great job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..)
Projects
None yet
Development

No branches or pull requests

8 participants