As I implement the MVVM pattern with WPF, I'm finding that ReSharper is often warning me that certain properties are never used in my ViewModels. The problem is that they are being used, but only by the data binding system. Has anyone else encountered this annoyance and is there a way to help ReSharper realize that these properties are, indeed, being used? I am glad, at least, that VS 2010 properly realizes that [Import] tagged members won't "always be null", but hopefully I can fix this issue as well.
You can use External Annotations to indicate to ReSharper the method is used and thus not to warn you. See the ReSharper docs on that here.
You need to decorate any such methods with [UsedImplicitlyAttribute]
.
Before using the attribute, you see:
and then, after applying the attribute:
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)] class NotUsed { public int Field1 { get; set; } public int Field2 { get; set; } }
Use
<UserControl ... xmlns:vm="clr-namespace:YourProject.ViewModels" mc:Ignorable="d" d:DataContext="{d:DesignInstance vm:SomeClassViewModel}">
It 'stick's View to Model. In View you could see model properties and vice versa - in model properties should be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With