[Bug]: ViewModelViewHost does not set DataContext in WPF
jhimes144 opened this issue ยท comments
Describe the bug ๐
In Avalonia, their ViewModelViewHost correctly sets the datacontext for a view to the wired view model. In WPF, the default ViewModelViewHost implementation does not do this, you are forced to manually set the DataContext after view activation. I suspect this is because the generic design of the ViewModelHost to allow it to work for various UI frameworks, because there is no code within to do this.
Step to reproduce
- Create a WPF app with a ViewModelViewHost with ViewModel set to a viewmodel with a view declared.
- Observe that bindings do not work.
Reproduction repository
https://github.com/reactiveui/ReactiveUI
Expected behavior
Using the ViewModelViewHost, should both render my view and bindings should work.
Screenshots ๐ผ๏ธ
No response
IDE
Rider Windows
Operating system
Windows
Version
11
Device
PC
ReactiveUI Version
19.5.39
Additional information โน๏ธ
No response
We don't set the DataContext by design. Rxui does not require it if you do rxui binding. The user can set the datacontext if they want with the rxui binding.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.