Thumb Drag in MVVM, WPF, C# -
i have 1 working app writen in c# wpf. practice working mvvm write same app mvvm. came problem. there in app use
<thumb dragdelta="thumb_drag" dragstarted="thumb_dragstarted" dragcompleted="thumb_dragcompleted" ... how write "drag&drop/draggable" example in mvvm? use "binding" or else? example welcome :) thanks!
if dont understand please ask me.
it's possible use system.windows.interactivitylibrary can added reference in project.
add namespace:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" and call commands through <i:invokecommandaction>:
<thumb> <i:interaction.triggers> <i:eventtrigger eventname="dragdelta"> <i:invokecommandaction command="{binding datacontext.thumbdragdeltacommand, relativesource={relativesource ancestortype={x:type window}}}" /> </i:eventtrigger> </i:interaction.triggers> </thumb> viewmodel:
private icommand thumbdragdeltacommand { get; set;} public mainviewmodel() //constructor { thumbdragdeltacommand = new delegatecommand(x => { //eventhandler //do stuff... } } you can, however, still handle event in code-behind while still being committed mvvm-pattern long events trigger graphical changes.
Comments
Post a Comment