uno icon indicating copy to clipboard operation
uno copied to clipboard

Can't use element name for Binding inside a Flyout

Open eriklimakc opened this issue 9 months ago • 2 comments

Current behavior

Works on Windows.

When trying to Bind a command from the Page ViewModel to a MenuFlyout that is inside an ItemTemplate using ElementName, the bind doesn't work.

Expected behavior

No response

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

Repro app: Flyout.zip

Workaround

No response

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

"Uno.Sdk": "5.2.121"
<UnoExtensionsVersion>4.1.21</UnoExtensionsVersion>
<UnoToolkitVersion>6.0.18</UnoToolkitVersion>
<UnoThemesVersion>5.0.13</UnoThemesVersion>
<UnoCSharpMarkupVersion>5.2.14</UnoCSharpMarkupVersion>

Affected platforms

WebAssembly, Android, Skia (WPF)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

eriklimakc avatar May 15 '24 17:05 eriklimakc

That's tricky to fix. When evaluating ElementName, we should be checking the current NameScope as well as the TemplatedParent NameScope.

Currently, we only check the current NameScope. To properly check the TemplatedParent's NameScope, we'll need #12732. Then, after this line:

https://github.com/unoplatform/uno/blob/3c45797b34e5fa0dda4b5fe16ca14cc4c39deaea/src/Uno.UI/DataBinding/BindingExpression.cs#L337

we should have target ??= NameScope.FindInNamescopes((_view?.Target as DependencyObject)?.TemplatedParent, elementNameSubject.Name);

Youssef1313 avatar May 31 '24 12:05 Youssef1313

@Youssef1313 now that https://github.com/unoplatform/uno/pull/17645 is merged, would be possible to proceed with this one? (Depending on the priority)

eriklimakc avatar Oct 11 '24 13:10 eriklimakc