Skip to content

Element with x:Load="False" still evaluates x:Bind in C++ #10941

@HO-COOH

Description

@HO-COOH

Describe the bug

If I understand this documentation correctly, when elements has x:Load=False, it should not evaluate x:Bind expression. But my getters are still called. This only happens in C++WinRT project, and does not happens in C#.

Why is this important?

This is a major blocker for me using x:Load with my model, and a major discrepancy to the documentation.

Steps to reproduce the bug

  1. Create a C++winui3 project using the default template
  2. Use this xaml
    <TextBlock
        x:Name="Text"
        x:Load="False"
        Text="{x:Bind MyProperty}" />
  1. Use this code
    int32_t MainWindow::MyProperty()
    {
        OutputDebugString(L"Getter called when it is not supposed to\n");
        return 42;
    }
  1. Put a breakpoint, on the line and build and run the app
  2. The breakpoint is hit, and the message is printed.

The equivalent C# code is working as expected!

        public int MyProperty
        {
            get
            {
                Debug.WriteLine("Getter called when it is not supposed to");
                return 42;
            }
        }

Actual behavior

No response

Expected behavior

No response

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.8.3: 1.8.251106002

Windows version

Windows 11 (24H2): Build 26100

Additional context

A full repro with both C++ and C#

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-C++/WinRTIssues related with C++/WinRT experiencebugSomething isn't working

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions