I'm templating a listbox. I like to show a path only if the item is selected.
The DataTemplate :
<DataTemplate x:Key="itplPlayerOfTheDay">
<Grid>
...
<Grid Width="50" Height="50" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,5,5,0">
<Path Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor , AncestorType={ListBoxItem}}, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" Data="M32.5569,7.54591 C32.3883,13.1553 31.3485,16.9274z" Stretch="Uniform" Stroke="Black" >
</Path>
</Grid>
...
</Grid>
</DataTemplate>
Apparantly there is something wrong with my XAML. In the designer is states : Cannot resolve symbol ancestor type.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…