Binding to the IsSelected property of the parent ListViewItem

大城市里の小女人 提交于 2019-12-04 02:16:07

I think that in this case you will have to use ElementName=ItemListView

Use Mode=FindAncestor:

<TextBlock Grid.Column="3" VerticalAlignment="Bottom"
          Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListViewItem}, Path=IsSelected, Converter={StaticResource boolConverter}, Mode=OneWay}">

@Murven 's answer was close. This is what worked for me:

<TextBlock Visibility="{Binding DataContext.IsSelected, ElementName=ItemListView Converter={StaticResource boolConverter}, Mode=OneWay}">

I had to use DataContext.IsSelected to access the context of the ItemListView. Not sure if there is a better way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!