开发者

How to get relative source of item in ItemTemplate

开发者 https://www.devze.com 2022-12-26 16:18 出处:网络
I have a ListBox with specified ItemTemplate. And the ItemTemplate contain itself ListView and I want to display in that ListView a collection, which is actually a property of the item of the ListBox.

I have a ListBox with specified ItemTemplate. And the ItemTemplate contain itself ListView and I want to display in that ListView a collection, which is actually a property of the item of the ListBox.

Could you show me how to do Binding. I'm thinking about RelativeSource thing, but I don't know what corre开发者_JS百科ct syntax would look like...


Nevermind, I found the answer.

it should be like this:

ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor,
                                     AncestorType={x:Type ListBoxItem}},Path=DataContext.YourCollectionProperty}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号