2012-10-18 7 views
0

에 사용되는 객체에, 저를 비난하지 마십시오)
I XAML에서 다음과 같은 부분이 있습니다 뒤에 뷰 클래스의 코드에서WPF, 참조가 나는 WPF 새로운 오전 XAML

<ListView x:Name="listView" IsEnabled="{Binding PropertiesEnabled}" Margin="0" 
      BorderThickness="0" DragDrop1:DropTargetBehavior.IsDropTarget="true" 
      MinHeight="300" DragDrop1:DropTargetBehavior.DropType="{x:Type UIP:DataItemViewModel}" 
      ItemsSource="{Binding dataItemCollection}" 
      SelectedItem="{Binding SelectedItem, Mode=TwoWay}" 
      AllowDrop="True" KeyDown="listView_KeyDown" MouseUp="listView_MouseUp" 
      UseLayoutRounding="False" VerticalContentAlignment="Center" 
      MaxWidth="Infinity" MaxHeight="1000" Grid.Column="1" 
      HorizontalContentAlignment="Stretch"> 

을, listView 및 IsEnabled, Margin, ItemsSource 등과 같은 대부분의 속성 및 특성에 액세스 할 수 있습니다. 그러나 DragDrop1에 대해서는 나열되지 않습니다.

일부 이벤트가 프로그래밍 방식으로 발생해야하기 때문에 DropTargetBehavior 유형 인 DragDrop1에 대한 참조를 가져와야하는 이유.

DragDrop1이 누락 된 원인은 무엇입니까? 어떻게 참조 할 수 있습니까?

건배.

답변

2

속성은 AttachedProperty이므로 ListView 개체의 일부로 실제로 존재하지 않습니다. 값에 액세스하려면 AttachedProperty 클래스 이름을 사용하고 값을 가져 오거나 설정하려면 매개 변수로 ListView을 전달해야합니다.

DragDrop1.DropTargetBehavior.GetIsDropTarget(listView)을 사용하거나 DragDrop1.DropTargetBehavior.SetIsDropTarget(listView, yourValue)

을 사용하여 설정할 수 있습니다.