Closed MartinZikmund closed 1 week ago
x:Bind to event does not work in Window-derived types, for repro see below
x:Bind
Window
Should work
Create a TestWindow.xaml with the following content:
TestWindow.xaml
<?xml version="1.0" encoding="utf-8" ?> <Window x:Class="WindowingSamples.TestWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="using:WindowingSamples.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid> <Button Click="MaximizeClick" HorizontalAlignment="Stretch" Content="Maximize" /> </Grid> </Window>
And TestWindow.xaml.cs with the following:
TestWindow.xaml.cs
<Button Click="{x:Bind Maximize}" HorizontalAlignment="Stretch" Content="Maximize" />
using Microsoft.UI.Windowing; namespace WindowingSamples; public sealed partial class MinimizeMaximizeWindow : Window { private OverlappedPresenter _presenter; public MinimizeMaximizeWindow() { InitializeComponent(); _presenter = (OverlappedPresenter)AppWindow.Presenter; } public void Maximize(object sender, RoutedEventArgs args) => _presenter.Maximize(); }
Put a breakpoint on Maximize method. Notice clicking the button does not hit the breakpoint on Uno targets, while it does on WinUI.
Maximize
Yes
Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
No response
WebAssembly, Android, iOS, Mac Catalyst, Skia (WPF), Skia (Linux X11), Skia (macOS), Skia (Linux Framebuffer), Skia (GTK), Windows (WinAppSDK)
Current behavior
x:Bind
to event does not work inWindow
-derived types, for repro see belowExpected behavior
Should work
How to reproduce it (as minimally and precisely as possible)
Create a
TestWindow.xaml
with the following content:And
TestWindow.xaml.cs
with the following:Workaround
Put a breakpoint on
Maximize
method. Notice clicking the button does not hit the breakpoint on Uno targets, while it does on WinUI.Works on UWP/WinUI
Yes
Environment
Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
NuGet package version(s)
No response
Affected platforms
WebAssembly, Android, iOS, Mac Catalyst, Skia (WPF), Skia (Linux X11), Skia (macOS), Skia (Linux Framebuffer), Skia (GTK), Windows (WinAppSDK)
IDE
No response
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response