dotMorten / WinUIEx

WinUI Extensions
https://dotmorten.github.io/WinUIEx
MIT License
572 stars 36 forks source link

Suggestion: Make `WindowEx` a FrameworkElement #174

Open veler opened 1 month ago

veler commented 1 month ago

Hi, First, thank you for this cool library ! I just hurt myself with this WinUI issue: https://github.com/microsoft/microsoft-ui-xaml/issues/4966

Long story short, Window isn't a FrameworkElement and it breaks the WinUI Source Code Generator when we try to use a x:Bind with a Converter expression inside.

A workaround is to do something like this:

<WindowEx (or Window)>
    <MyUserControl />
</WindowEx>

and MyUserControl being:

<UserControl>
   <TextBlock Text="x:Bind ViewModel.MyText, Converter=...blablabla"/>
</UserControl>

This issue took me 2 hours, mainly because I'm more used to WPF than WinUI and as someone said on the issue I linked above:

Yeah, I too keep getting tripped up that Window isn't a DependencyObject... it's a bit weird.

So here is a suggestion, if I may:

Make WindowEx inheriting from Page or UserControl and expose every Window properties/methods into it. So, for example, the Width property of this UserControl based WindowEx would not control the width of the UserControl, but the width of the underlying window, which can also be exposed as a property of WindowEx.

What do you think? Thanks