I've got a FlipView that shows Figurines. Figurines contain a Path to their image.
Binding this property to a regular DataTemplate is ok. (the code below works fine)
</DataTemplate>
<Canvas x:Name="DefaultImageCanvas" Width="660" Height="372">
<Image Name="imageFlip" Width="660" Height="372" Source="{Binding Path}"
Stretch="Uniform" />
</Canvas>
</DataTemplate>
But when using my UserControl instead, it doesnt work anymore:
<DataTemplate>
<local:FigurineStickerUserControl Width="660" Height="372"
FigurinePath="{Binding Path}"/>
</DataTemplate>
The FigurinePath DP is never set. (If I use a hardcoded string, its fine.) Here is the error in the output:
Error: BindingExpression path error: 'Path' property not found on 'Com.Test.ViewModels.UserControl.FigurineStickerUserControlViewModel, eSmart.ViewModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. BindingExpression: Path='Path' DataItem='Com.Test.ViewModels.UserControl.FigurineStickerUserControlViewModel, Test.ViewModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'Com.Test.Views.FigurineStickerUserControl' (Name='pageRoot'); target property is 'FigurinePath' (type 'Object')
It looks like the DataTemplate tries to assign the Figurine as the DataContext of my UserControl, then retrieve the property from my UC's DataContext. But my UC has its own DataContext (its ViewModel) and I don't want to remove it.
Unfortunately with WinRT/UWP there is no FindAncestor tricks that I can do with the Binding. I already tried this: (FlipFigurine being the FlipView object)
<local:FigurineStickerUserControl Width="660" Height="372"
FigurinePath="{Binding SelectedItem.Path, ElementName=FlipFigurine}"/>
It doesnt work. Even changing the DP to object and trying the following doesnt work, the setter of the DP is never called. No error in the log though.
FigurinePath="{Binding SelectedItem, ElementName=FlipFigurine}"
Is there any way to access the actual Figurine object and simply bind its Path property to the FigurinePath property of my UC??