WPF Popup in a separate visual tree
I have custom list box in WPF with the following type o开发者_开发技巧f listbox item:
<MyListBoxItem>
<Canvas>
<MyControl/>
<Popup />
</Canvas>
</MyListBoxItem/>
This is just an example to explain things. My list box items are actually templated.
Now MyListBoxItem 'must' eat previewMouseDown events for custom selection logic. I'd like the popup to open up in its own visual tree so that mouse down events in the popup aren't eaten up by the listboxitem. Is there some way of achieving this? Adorners come to mind but I'd like to do this purely in XAML and am wondering if there is some simple way of achieving this.
You could try placing the popup in the Canvas.Resources
, you should still be able to use it but it should be disconnected from the Visual Tree entirely.
精彩评论