SuperAllumette
SuperAllumette

Reputation: 109

How to enable drop on an image that is not drawn?

That might be a silly question, but I just can figure how to resolve it for now.

I'm building a wpf application with drag and drop between a ListView and a Grid. My items being consituted by an Image and a TextBlock. I have defined a DataTemplate with a StackPanel containing these controls and applied it to ListView items and ContentControls inside of the Grid cells. Basic idea is to chose items from the ListView and drag them to a cell. So my grid is empty at the beginning. My problem, besides of sucking at making my controls filling correctly my grid (bonus ninja question !), is that when no item is chosen in a cell the image is not drawn and will not act as drop target. Only the TextBlock will.

Is there a way to counter that ? Thank you :)

Upvotes: 1

Views: 81

Answers (1)

Lee Louviere
Lee Louviere

Reputation: 5262

You can set a datatemplate trigger so that you display an empty image that will accept the drop, if the contents are null.

And if that idea doesn't work, you can create a datatemplateselector that returns a template with a blank dropping target if the content is null. This shows how to make a selector that can let you set all possible templates using only xaml.

Upvotes: 1

Related Questions