Resharper and WPF MVVM
Hi,
I've got problem with finding code issues in WPF project. Currently I'm using Resharper 2016.2.2.
It's suggesting that public Properties in ViewModel should be private, but they can't be private (according to MVVM mechanism to work properly). Is there any solution for this problem?
I've read that I can use Agent Mulder pluggin, but my team doesn't want to use Agent Mulder plugin because it's not supported anymore.
Please sign in to leave a comment.
Have you tried adding a design-time datacontext to your view?
Many thanks for your fast answer. I didn't know anything about design-time datacontext. Now I have tested it and found it very usefull. But it still doesn't solve my main problem.
When I'm setting DataContext in View problem doesn't exist. The problem is when I'm setting view's DataContext in code behind. I can't set DataContext in View because my ViewModel class doesn't have parametless constructor.
There are some suggestions for workarounds on this StackOverflow thread.
You don't need to set the DataContext in the XAML; you just need to set the design-time DataContext (d:DataContext), so that R# knows that the view and viewmodel are linked. Any properties you use in the view should then not be marked as "unused", and the view should be included in the "usages of" navigation.
Many thanks Richard for your help. I've installed newest version of Resharper, rebuilded project and it works:-)
It works only when I'm using design-time datacontext you have send.