Skip to content

Border with ImageBrush no longer shows after setting Opacity to 1 with initial value 0 #10760

@HO-COOH

Description

@HO-COOH

Describe the bug

If I have a Border painted with ImageBrush

        <Border
            x:Name="MyImage"
            Width="100"
            Height="100"
            CornerRadius="96"
            Opacity="0">
            <Border.Background>
                <ImageBrush ImageSource="ms-appx:///Assets/Owl.jpg" />
            </Border.Background>
        </Border>

It no longer shows after I set its Opacity to 1 in code-behind

    MyImage().Opacity(1);

If you give Opacity an initial value to something non-zero, like 0.5, it behaves as expected.

Why is this important?

This is blocking my project

Steps to reproduce the bug

  1. Create a winui3 C++ project
  2. In MainWindow.xaml
    <StackPanel HorizontalAlignment="Stretch">
        <Border
            x:Name="MyImage"
            Width="100"
            Height="100"
            CornerRadius="96"
            Opacity="0">
            <Border.Background>
                <ImageBrush ImageSource="ms-appx:///Assets/Owl.jpg" />
            </Border.Background>
        </Border>
        <Button Click="Button_Click">Opacity set</Button>
    </StackPanel>
  1. In code-behind
void winrt::WinUI3Cpp::implementation::MainWindow::Button_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e)
{
    MyImage().Opacity(1);
}
  1. Run project, click the button, the image is not shown

Actual behavior

No response

Expected behavior

The image should show after setting its opacity to non-zero

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.7.3: 1.7.250606001

Windows version

Windows 11 (23H2): Build 22631

Additional context

This issue does NOT happen with a regular Image control

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageIssue needs to be triaged by the area owners

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions