Compiled Binding don't work with a ViewModelLocator
See original GitHub issueDescribe the bug I want to use CompiledBinding with a ViewModelLocator as a StaticRessource
To Reproduce Steps to reproduce the behavior:
- Create a view
- Declare your viewmodel into App.axaml as a StaticResource
- Bind your viewmodel and set CompileBindings into the view like this :
DataContext="{Binding MainWindowViewModel, Source={StaticResource ViewModelLocator}}"
x:DataType="viewModels:MainWindowViewModel"
x:CompileBindings="True"
Expected behavior Using compiledBinding with my ViewModelLocator
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Windows/Mac
- Version Avalonia 0.10.17
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
wpf - ViewModelLocator not firing up
The user control's data context is a ViewModelLocator and the button is binding to MoCoConnectCommand property.
Read more >DataContext And Autowire In WPF
One way is to bind DataContext Property within a XAML, Second is to assign DataContext within Code-Behind and last using ViewModelLocator.
Read more >Getting Started with Prism's new ViewModelLocator
Learn how to use the new ViewModelLocator that ships with the new Prism ... If you try to run the application as is,...
Read more >The Model-View-ViewModel Pattern - Xamarin
The binding of views to a property in a data source should be the view's principal dependency on its corresponding view model. Specifically,...
Read more >Design-Time Binding Contexts in Xamarin.Forms Using ...
We implement a static class named ViewModelLocator and use a static, readonly property to return an instance of the object we want our...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
See: https://github.com/AvaloniaUI/Avalonia/issues/3635#issuecomment-1178553552 for an example.
Hi,
Thanks @timunie, I just checked and It works ! I’ll just send a ticket to AvaloniaRider because this trick is considered as a error in Rider 😃 And confirm your PR on my repo