Heres a simple question. I’ve got a XAML that at the moment looks like this:
<ListBox>
<ListBox.ContextMenu>
<ContextMenu DataContext="{Binding Path=FeedContextMenu}"
</ListBox.ContextMenu>
</ListBox>
My intention is to take the data context from the ListBox and use its FeedContextMenu property as a DataContext for ContextMenu. Now all you WPF gurus will probably immediately say that this will not work. Apparently, this has something to do with the fact that ContextMenu isn’t part of the visual tree. Now I’m not a WPF expert, so after googling for hours and trying out different suggested solutions that didn’t work nor make any sense to me whatsoever, I would like to ask someone with a greater knowledge to explain it to me what and why needs to be done in order for this to work. Thanks.
You could try to bind to the DataContext of the ContextMenu’s PlacementTarget (which is the ListBox) like this: