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

Twoway x:bind Doesn't Work Correctly On Different Platforms #18509

Open
NoobNotFound opened this issue Oct 18, 2024 · 4 comments
Open

Twoway x:bind Doesn't Work Correctly On Different Platforms #18509

NoobNotFound opened this issue Oct 18, 2024 · 4 comments
Labels
area/xBind 🪢 Categorizes an issue or PR as relevant to x:Bind difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working

Comments

@NoobNotFound
Copy link

Current behavior

I've created a item template for a navigationview item with a model. I've set it to capture the selection state by adding a another navview item with two-way bindings like this

<NavigationView.MenuItemTemplate>
   <DataTemplate x:DataType="local:SquareNavigationViewItem">
        <NavigationViewItem
              Height="64"
              IsEnabled="{x:Bind IsEnabled, Mode=OneWay}"
              IsSelected="{x:Bind IsSelected, Mode=TwoWay}">
...

and it is used to hide the labels in navigationview item like this

  <TextBlock
       x:Load="{x:Bind IsSelected.Equals(x:False), Mode=OneWay}"
       Style="{StaticResource CaptionTextBlockStyle}"
       Text="{x:Bind Name}" />

As I've tested, this seems to work fine on Windows and Android platform. But It is messing around with MacOS, Skia (MacOS) and WASM. (Didn't build with IOS)
Sometimes the label only gets hidden and shown once, which means the properties doesn't get properly binded after that (as I understand)

Expected behavior

The MacOS platforms should be same as the Windows and Android

How to reproduce it (as minimally and precisely as possible)

  • Create an Uno app through:
  • dotnet new install Uno.Templates
  • I've uploaded a demo project zi, you can use it or make your own.

UnoApp1.zip

Workaround

No response

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

  • CommunityToolkit.Mvvm : 8.3.2
  • "Uno.Sdk": "5.4.8"

Affected platforms

Mac Catalyst, Skia (macOS)

IDE

Visual Studio 2022, Visual Studio Code

IDE version

VS Version 17.12.0 Preview 1.0, VS Code Version: 1.95.0-insider

Relevant plugins

No response

Anything else we need to know?

Another thing I found,
Even though this uses the same code It looks streched on some platforms (which is okay, I can manually make them)

  • WASM and WinUI (Bindings works fine only on WinUI)

image

  • Android With Debug Logs (Bindings works fine here)

Screenshot 2024-10-18 at 9 11 03 AM Screenshot 2024-10-18 at 9 17 50 AM
  • MacOS With Debug Logs

Screenshot 2024-10-18 at 9 13 58 AM Screenshot 2024-10-18 at 9 15 40 AM

Although this is my understanding, I'm not sure whether this is a problem with two-way binding or with controls or with mine, so correct me if I'm wrong

@NoobNotFound NoobNotFound added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Oct 18, 2024
@jeromelaban
Copy link
Member

Thanks for the report. Could you check using the latest 5.6-dev preview bits?

@jeromelaban jeromelaban added area/xBind 🪢 Categorizes an issue or PR as relevant to x:Bind and removed triage/untriaged Indicates an issue requires triaging or verification labels Oct 18, 2024
@NoobNotFound
Copy link
Author

Thanks for the report. Could you check using the latest 5.6-dev preview bits?

umm... You mean the SDKs? How can I upgrade? the SDKs to preview versions?

@jeromelaban
Copy link
Member

Yes, there's only one version to update (https://www.nuget.org/packages/Uno.Sdk) then follow the directions for updating the uno.sdk in your project.

@NoobNotFound
Copy link
Author

NoobNotFound commented Oct 19, 2024

@jeromelaban hi, with the following global.json the result was the same

{
  "msbuild-sdks": {
    "Uno.Sdk": "5.6.0-dev.24"
  },
  "sdk":{
    "allowPrerelease": true
  }
}

but...
Upon further reviewing what I noticed is that two-way binding does seem to work correctly, but the issue is with unloading the textblock. If I made it to change the visibility, it would work.

<TextBlock x:Load="{x:Bind IsSelected.Equals(x:False), Mode=OneWay}"
...

Also It's not because of .Equals(x:False). I tested without it, the result was the same (except, it hides when it's doesn't need to hide...)

So Should I close this issue because it doesn't seems to be an issue with x:bind or just rename it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/xBind 🪢 Categorizes an issue or PR as relevant to x:Bind difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants