2013-03-05 85 views
2

我模板列表框。我只想在選擇該項目時顯示路徑。WindowsPhone:RelativeSource Mode = FindAncestor,AncestorType:CannotResolve SymbolAncestorType

的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。在設計師說明中:無法解析符號祖先類型。

+0

請不要在標題中放入代碼... – 2013-03-05 20:05:46

回答

5

AncestorType在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中進行一些更改並完成!

+0

我在MyView中添加了一個額外的屬性來照顧可見/不可見狀態 – Brilbroeder 2013-03-11 18:08:53