Move items in a canvas using MVVM

后端 未结 4 1370
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 11:28

I want the user to be able to move items freely in a canvas.
My app is using Caliburn.Micro.

My MainViewModel has a collection if Items :

public          


        
4条回答
  •  春和景丽
    2021-01-03 12:25

    If you're wondering how to do it in a nice way, then I would say that you're looking something a long of the lines:

    
    

    where MouseButtonMoved is an attached property (of type ICommand) that hooks itself into the ItemsControl MouseButtonMove event, and then executes the the command it is binded against, passing two double values (x, y) through the MouseButtonMoved.Execute(x, y).

    If you want to see similiar implementations, check for gongdrop implementation. I'd use that as a solution, but if you want to rewrite it from zero, just read the source.

提交回复
热议问题