TemplateStudio icon indicating copy to clipboard operation
TemplateStudio copied to clipboard

`x:Bind` Not Working?

Open myokeeh opened this issue 1 year ago • 0 comments

Describe the bug

I just created a Menu Bar WinUI project. All Nuget packages updated.

MainPage.xaml

        <TextBlock Grid.Row="0"
                   x:Uid="Main_Title"
                   Style="{StaticResource PageTitleStyle}" />
        <!--line below added for testing-->
        <TextBlock><Run Text="{x:Bind ViewModel.Busytext1, Mode=OneWay}"></Run></TextBlock>

MainViewModel.cs:

    [ObservableProperty]
    public string _busytext1 = "test";

To Reproduce

  1. Create new Menu Bar WinUI Template Studio project
  2. Add xaml code above to MainPage.xaml
  3. Add code above to MainViewModel.cs.
  4. Set Property Busytext1 to some text via code behind.
  5. UI isn't updated. Remains as "text" value

Additional context

I'm coming from UWP and used Windows Template Studio. I didn't run into issues like this.

I tried adding/setting datacontext or adding similar xaml code that referenced the viewmodel, but can't get binding to work.

Binding works on load, but subsequent attempts to set the Properties that are bound don't work.

Applies to the following platforms:

  • [X] WinUI
  • [ ] WPF
  • [ ] UWP

About your setup

  • Visual Studio Version: 2022 17.9.6
  • Template Studio Wizard Version: 5.5
  • Windows Build: 24H2 26100.1

myokeeh avatar Apr 24 '24 06:04 myokeeh