❔ Porting a mvvm based WPF application to WinUI 3
I am trying to rewrite a WPF application that is based on the mvvm pattern into WinUI 3. Now I already fail at the MainWindow.
In WPF, I usually don't have any content in the MainWindow, I only use it to fill in the views I then fill with content. I use
Window.DataContext
and Window.Resources
for that, as follows:
Now this seems not to work anymore in WinUI 3, as VS keeps telling me that Window
doesn't have these properties. How would I do that same thing in WinUI 3?5 Replies
What properties?
Title
? It's not bindable in WinUI3 unless it was changed very recently in the newest version. You need to be specific when describing errors.
Also, you should be using x:Bind
in WinUI3 instead of Binding
once you get things under control.I am talking about
Window.DataContext
and <Window.Resources>
Well, the short answer for that is that you need to find another approach because
Window
isn't a FrameworkElement
in WinUI3/UWP, so it doesn't have those properties.You need to put it inside the root content (the grid in this case).
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.