When I bind something to the SelectedItem
of a ListView using ElementName
, the properties cannot be resolved.
I can still build and run my app, but because of this error I'm not sure that I didn't make any typo's.
I read and tried the answer given in ElementName Binding is failing but Source={x:Reference ...}
doesn't seem to exist in the WinRT framework.
Just an example:
My page has a property MyContainerObject
with an IEnumerable<MyParentObject>
inside called MyParents
. Each MyParentObject
has an IEnumerable<MyChildObject>
called MyChildren
inside.
The DataContext of my page:
DataContext="{Binding RelativeSource={RelativeSource Self}}"
I have ListView with the following XAML properties:
x:Name = "FirstListView"
ItemsSource = {Binding MyContainerObject.MyParents}
Then I have another ListView with the following XAML properties:
x:Name = "SecondListView"
ItemsSource = "{Binding SelectedItem.MyChildren, ElementName=FirstListView}"
Now ReSharper gives me the following warning:
Cannot resolve property 'MyChildren' in data context of type 'object'.