이벤트 처리를 위해 WPF, MVVM 및 비헤이비어를 사용하는 데스크톱 응용 프로그램을 수정해야합니다. 단추를 놓기 위해 드래그 & 놓기를 구현하는 작업이 있습니다. 사용자가 버튼을 누르면 파일 저장 윈도우가 팝업되지만 사용자가 클릭하여 드래그하면 파일 아이콘이 표시되고 사용자가 Explorer 창에 파일 아이콘을 저장하면 저장됩니다.비헤이비어로 드래그 앤 드롭 추가
이미 추가 한 네임 스페이스 :
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:MyApplication.Desktop.Client.Behaviors"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:command="http://www.galasoft.ch/mvvmlight"
나는 또한 버튼으로 XAML 코드를 추가했습니다 :
<Button Grid.Column="2"
Command="{Binding SaveAttachmentCommand}"
Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource boolToVisibilityConverter}}"
Style="{StaticResource AttachmentSaveButtonStyle}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseLeftButtonDown">
<command:EventToCommand Command="{Binding LeftMouseButtonDownCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<i:Interaction.Behaviors>
<behaviors:FrameworkElementDragBehavior>
</behaviors:FrameworkElementDragBehavior>
</i:Interaction.Behaviors>
</Button>
하지만 (FrameworkElementDragBehavior를 동작 클래스를 이야기하는 방법을 모른다) 처리 할 이벤트와 처리 방법 (호출 할 함수)을 지정합니다.
일부 자습서를 읽었지만 여전히 혼란 스럽습니다.