我是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时,它没有列出。
我之所以需要引用DragDrop1(类型为DropTargetBehavior),是因为某些事件应该以编程方式触发。
可能是缺少DragDrop1的原因是什么?我该如何参考呢?
干杯。
答案 0 :(得分:2)
该属性是AttachedProperty
,因此它实际上并不作为ListView
对象的一部分存在。您需要使用AttachedProperty
类名来访问该值,并将ListView
作为参数传递给它以获取或设置该值。
您可以使用DragDrop1.DropTargetBehavior.GetIsDropTarget(listView)
获取或使用DragDrop1.DropTargetBehavior.SetIsDropTarget(listView, yourValue)