reactiveui / ReactiveUI

An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.

Home Page:https://www.reactiveui.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[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

  1. Create a WPF app with a ViewModelViewHost with ViewModel set to a viewmodel with a view declared.
  2. 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.