Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a class Person ,which contains three properties ,they are name,age,address.And I have three listbox to display these three properties separately .In addition ,another ListboxDragDropTarget was used to receive the items dragged from these three listbox and then to form a complete person object. What I have encountered was that I used the following
text={Binding name}
text={Binding age}
text={Binding address}

but when I dragged an item from one of the three listbox ,the target listbox just simply receive the whole person property ,which was not just the single item I dragged. Any good ideas to solve my questions?
Posted

1 solution

A listbox does not have columns. You can in WPF ( which Silverlight is ) set up any rendering of an object you like, but drag and drop will always drop the entire object. Unless you can do some ugly work with working out the point where the drag started and what was rendered there, you may find you need to use a control with columns like a Grid[^]. I'm not sure how drag and drop works between grids, but, if you need to know the column, then a control with actual columns is your only real hope.
 
Share this answer
 
Comments
JustForHelp 25-Aug-12 21:33pm    
What does "column" mean? Is it the same as "row",if yes ,I think you may have misunderstood my thought.What I want to do is that ,if there is a person object like this :name ="Bob" age="20" address="New York" ,I want the listbox display it with three rows in order like this:
Bob
20
New York
Do you understand me? Hope for your answer!
Best Regards,
JustForHelp
Christian Graus 26-Aug-12 7:15am    
xxxxx
yyyyy

Here, a row is xxx or yyy, a column is xy. In your data, a column is an age, a name or an address. You show all of this as one string, b/c your control has only one column. If it had three, you'd have one for name, one for age, one for address.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900