Hello,
I have a ListView and a Header with HeaderTemplate.
The HeaderTemplate is in an extra .xaml file, so that I can reuse it.
<ListView.HeaderTemplate>
<DataTemplate>
<my:HeaderControl />
</DataTemplate>
</ListView.HeaderTemplate>
public class MyViewModel {
public Command SomeCommand;
public MyObject MyObject;
}
The Header is bound to MyObject, but needs also to call the SomeCommand command.
So I wrote a MarkupExtension which allows me to get the ParentPage.
{Binding Path=Vm.SomeCommand, Source={myex:ParentPage}}
public static Page ParentPage(this Element element)
{
while (element != null && !(element is Page))
element = element.Parent;
return element as Page;
}
Now the problem:
If u use an external (reusable) xaml file in a ListView's DataTemplate there is no parent set for the external control.
Any ideas on this?