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

Button content disappears in version 11.2.0-rc2 #17376

Closed
ADdy2142 opened this issue Oct 29, 2024 · 3 comments · Fixed by #17402
Closed

Button content disappears in version 11.2.0-rc2 #17376

ADdy2142 opened this issue Oct 29, 2024 · 3 comments · Fixed by #17402
Labels

Comments

@ADdy2142
Copy link

Describe the bug

Hello
Today I installed Avalonia version 11.2.0-rc2. I encountered a strange problem that I had to downgrade to version 11.1.4, which is a stable version. When I upgraded Avalonia to version 11.2.0-rc2, the Content I intended for the Button disappeared. If I changed the HorizontalAlignment or VerticalAlignment of the TextBlock inside the Button from DevTools, the text of the Button would be temporarily displayed, but it would disappear again after changing the window size.
I did not have this problem in the previous version, but after the upgrade I encountered this problem.
When I reduced the size of the window to its minimum, the text inside the button was visible. It was as if the text was stuck to the left or right (based on FlowDirection) side of the window, and then the text would fall into place after the window was resized.
Screenshot 2024-10-29 085242
Screenshot 2024-10-29 085343
Screenshot 2024-10-29 085731

My button style is defined as below:

<Style Selector="Button.startExam">
    <Setter Property="Margin" Value="0" />
    <Setter Property="Padding" Value="32,14" />
    <Setter Property="HorizontalAlignment" Value="Center" />
    <Setter Property="HorizontalContentAlignment" Value="Center" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Background" Value="#C1E4E5" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="CornerRadius" Value="20" />
    <Setter Property="FontFamily" Value="{DynamicResource Vazirmatn}" />
    <Setter Property="FontSize" Value="32" />
    <Setter Property="FontWeight" Value="Bold" />
    <Setter Property="Foreground" Value="#3A4F55" />
    <Setter Property="RenderTransform" Value="scale(1)" />

    <!--  Template  -->
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Border Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding CornerRadius}">
                    <ContentPresenter Name="StartExamButtonContentPresenter"
                                      Margin="{TemplateBinding Padding}"
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                      Content="{TemplateBinding Content}"
                                      FontFamily="{TemplateBinding FontFamily}"
                                      FontSize="{TemplateBinding FontSize}"
                                      FontWeight="{TemplateBinding FontWeight}"
                                      Foreground="{TemplateBinding Foreground}" />
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>

    <!--  Transitions  -->
    <Setter Property="Transitions">
        <Setter.Value>
            <Transitions>
                <TransformOperationsTransition Property="RenderTransform"
                                               Duration="00:00:00.3" />
            </Transitions>
        </Setter.Value>
    </Setter>

    <!--  Pointer over  -->
    <Style Selector="^:pointerover">
        <Setter Property="RenderTransform" Value="scale(1.05)" />
    </Style>

    <!--  Disabled  -->
    <Style Selector="^:disabled">
        <Setter Property="RenderTransform" Value="scale(1)" />
        <Setter Property="BorderBrush" Value="#A8D0D2" />
        <Setter Property="Foreground" Value="#A8D0D2" />

        <Style Selector="^:pointerover">
            <Setter Property="RenderTransform" Value="scale(1)" />
        </Style>
    </Style>

    <!--  Tablet styles  -->
    <Style Selector="^.tablet">
        <Setter Property="Padding" Value="28,12" />
        <Setter Property="CornerRadius" Value="18" />
        <Setter Property="FontSize" Value="28" />
    </Style>

    <!--  Mobile styles  -->
    <Style Selector="^.mobile">
        <Setter Property="Padding" Value="24,10" />
        <Setter Property="CornerRadius" Value="16" />
        <Setter Property="FontSize" Value="24" />
    </Style>
</Style>

And this is my button:

<Button Classes="startExam"
        Command="{Binding $parent[local:StartView].StartExamCommand}"
        CommandParameter="{Binding $parent[local:StartView].StartExamCommandParameter}"
        Content="اجرای آزمون"
        IsEnabled="{Binding StartButtonIsEnabled}" />

To Reproduce

Upgrade to version 11.2.0-rc2

Expected behavior

The text inside the Button should be displayed in the middle of it

Avalonia version

11.2.0-rc2

OS

Windows

Additional context

No response

@ADdy2142 ADdy2142 added the bug label Oct 29, 2024
@maxkatz6
Copy link
Member

@Gillibald does it sound as a text processing bug?

@Gillibald
Copy link
Contributor

This was an issue before #17271

Need to verify

@DoubleDBE
Copy link

Can concur, same here on the latest stable (11.2.0).

On 11.2.0-rc1 I had no issues at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants