Right. So moving from WPF to UWP, I'm trying to use x:Bind
to get compile-time benefits. Simple scenarios work fine; however I have found a number of issues that I was not able to solve. They are all related, so I thought I'd post them in one place:
- I haven't been able to make Intellisense work with
x:Bind
. I have set DataContext (as well asd:DataContext
just as we do in WPF) both in XAML and in the constructor, but it won't show members no matter what. Has anyone done this successfully? - Then I read somewhere that in UWP,
DataContext
is always set toPage
's code-behind (really??) and that I need to define a ViewModel type property in the code-behind and then use that property inx:Bind
. Is this correct? I tried it and it works but gives rise to the next question. - If I define a property of ViewModel type in Page's code-behind, Any sub-properties that raise
PropertyChanged
notifications do not update the UI. For example, if the code-behind property is namedGame
(of typeGameVM
) and there is a public property inGameVM
namedPlayer
(of typeGamePlayer
), and in turnGamePlayer
contains a property namedName
, thex:Bind
path will look like{x:Bind Path=Game.Player.Name}
. But if I do this, any change notifications raised from withinName
property do not update Page's UI.
One alternate I tried was to listen to PropertyChanged at each level and then bubble it up the hierarchy, but that hasn't worked. Even if it does, doing this seems a bit too much work. In WPF sub-properties like Game.Player.Name
work properly without having to doing property change bubbling. Or am I missing something?