本文介绍了WindowsPhone的:的RelativeSource模式= FindAncestor,AncestorType:CannotResolve SymbolAncestorType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在模板化一个列表框。我喜欢展示一个路径,如果该项目被选中。

I'm templating a listbox. I like to show a path only if the item is selected.

在DataTemplate的:

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有什么不对我的XAML。在设计师的状态:无法解析符号的祖先类型。

Apparantly there is something wrong with my XAML. In the designer is states : Cannot resolve symbol ancestor type.

推荐答案

AncestorType不支持Windows Phone上。

AncestorType is not supported on Windows Phone.

<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一些改变,做!

Make some changes in your BooleanToVisibilityConverter and done!

这篇关于WindowsPhone的:的RelativeSource模式= FindAncestor,AncestorType:CannotResolve SymbolAncestorType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 23:34