I am new to WPF, please do not blame me 😉
I have the following part in 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">
In the code behind for the view class, I am able to access listView and most of its properties and attributes like IsEnabled, Margin, ItemsSource etc. However, when it comes to DragDrop1, it is not listed.
The reason why I need to get reference to DragDrop1, which is of type DropTargetBehavior, because some events should be fired programmatically.
What could be the cause of missing DragDrop1? How to I get reference to it?
Cheers.
The property is an
AttachedProperty, so it doesn’t actually exist as part of theListViewobject. You need to use theAttachedPropertyclass name to access the value, and pass it theListViewas a parameter to get or set the value.You can get it using
DragDrop1.DropTargetBehavior.GetIsDropTarget(listView)or set it usingDragDrop1.DropTargetBehavior.SetIsDropTarget(listView, yourValue)