You are right, ReSharper does not know how RowStyle will be used in this particular control (is it a style for each ItemsSource ? Or some kind of header style, and the bindings will have access to the ItemsSource object?), So it stops moving the tree looking for the type DataContext in a Style declaration.
This issue can be resolved with additional annotation in the Style declaration:
<Style TargetType="DataGridRow" d:DataContext="{d:DesignInstance vms:ItemVM}"> <Setter Property="Header" Value="{Binding Name}" /> </Style>
The project will compile fine, the VS and R # constructor will work, but support for VS xaml will result in 1 error in the error window - the "DataContext" cannot be attached to elements of the "Style" type. This is a little annoying but works. Another way is to quilify the type of the property as follows:
<Style TargetType="DataGridRow"> <Setter Property="Header" Value="{Binding (vms:ItemVM.Name)}" /> </Style>
But it also causes a VS xaml support error :) and has a slightly different runtime behavior - this binding will only work with the Name property of the ItemVM type and will not work if somehow the VM object is replaced with some other object of another type with the Name attribute at runtime (therefore, the binding has become "strongly typed").
We are still looking for the best way to solve such problems in ReSharper 8.0 and make the VS designer happy, sorry for the confusion!
Controlflow
source share