question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compiled Binding don't work with a ViewModelLocator

See original GitHub issue

Describe the bug I want to use CompiledBinding with a ViewModelLocator as a StaticRessource

To Reproduce Steps to reproduce the behavior:

  1. Create a view
  2. Declare your viewmodel into App.axaml as a StaticResource
  3. 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:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

0reactions
Tenjimcommented, Sep 8, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found