Xaml WindowsPhone:RelativeSource模式=FindAncestor,取消存储类型:无法取消符号取消存储类型

Xaml WindowsPhone:RelativeSource模式=FindAncestor,取消存储类型:无法取消符号取消存储类型,xaml,binding,windows-phone,Xaml,Binding,Windows Phone,我正在制作一个列表框的模板。我只想在选中项目时显示路径 数据模板: <DataTemplate x:Key="itplPlayerOfTheDay"> <Grid> ... <Grid Width="50" Height="50" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,5,5,0"> <Path Visib

我正在制作一个列表框的模板。我只想在选中项目时显示路径

数据模板:

<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>

...
...

很明显,我的XAML有问题。设计器中的is状态:无法解析符号祖先类型。

Windows Phone不支持AncestorType

<DataTemplate x:Key="itplPlayerOfTheDay">
    <Grid>
        ...
        <Grid Width="50" Height="50" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,5,5,0">
            <Path Visibility="{Binding ElementName=yourListBoxName, Path=SelectedItem, Converter={StaticResource BooleanToVisibilityConverter}}"  Data="M32.5569,7.54591 C32.3883,13.1553 31.3485,16.9274z" Stretch="Uniform" Stroke="Black" >
            </Path>
        </Grid>
        ...
    </Grid>
</DataTemplate>  

...
...

在BooleanToVisibilityConverter中进行一些更改,然后完成

请不要在标题中添加代码…我在MyView中添加了一个额外属性来处理可见/不可见状态