AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.06k stars 2.25k forks source link

Change TextBlock.Text in invisible StackPanel with horizontal orientation #17492

Open RomanTimv opened 1 week ago

RomanTimv commented 1 week ago

Describe the bug

TextBlock doesn't display text if it was changed when containing StackPanel with horizontal orientation was invisible. Grid or vertical StackPanel works correctly

To Reproduce

Place on View:

In Button.Click handler set TextBox.Text to "Test" and StackPanel.IsVisible to true

StackPanel becomes visible (green stripe) but without text in it

Expected behavior

StackPanel text is visible in StackPanel

Avalonia version

11.2.0

OS

Windows

Additional context

No response

Gillibald commented 1 week ago

Please test against current master

RomanTimv commented 1 week ago

Same behavior.

  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <StackPanel  Name="cv" Orientation="Vertical" Grid.Row="0" Margin="4" HorizontalAlignment="Stretch" Background="LightGreen" IsVisible="False">
      <TextBlock Name="tv" />
    </StackPanel>

    <StackPanel Name="ch" Orientation="Horizontal" Grid.Row="1" Margin="4" HorizontalAlignment="Stretch" Background="LightGreen" IsVisible="False">
      <TextBlock Name="th" />
    </StackPanel>

    <Button Grid.Row="2" Margin="4" Content="Show" Click="Button_Click" />
  </Grid>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            cv.IsVisible = true;
            tv.Text = "Test";

            ch.IsVisible = true;
            th.Text = "Test";
        }

On button click I got image