views:

67

answers:

1

I'm creating a drag and drop behavior, and the goal is to drag an item onto my grid, where a set of adorned elements representing the available actions will be available for the user to drop the element on. My problem is once I add the adorned element(s) to the AdornerLayer, I don't receive any Drag events. I need to get those events to both change UI and set some underlying properties. I've set AllowDrop=true on the AdornerLayer, the adorned element, my button inside the DataTemplate inside the ContentPresenter, and on the ContentPresenter itself, but still don't get any events.

<DataTemplate x:Key="promoMediaTemplate" DataType="{x:Type media:PromoMediaSearchResult}">
<Button Content="{Binding Path=Description}" Name="item" AllowDrop="True" Background="Red" /
<DataTemplate.Triggers>
    <EventTrigger RoutedEvent="Button.PreviewDragEnter">
        <BeginStoryboard x:Name="TextBeginStoryBoard">
            <Storyboard>
                <ColorAnimation 
                    Storyboard.TargetName="item"
                    Storyboard.TargetProperty="Background"
                    Duration="0:0:1.0"
                    From="Red" To="Green" />
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
    <EventTrigger RoutedEvent="Button.PreviewDragLeave">
        <StopStoryboard BeginStoryboardName="TextBeginStoryBoard" />
    </EventTrigger>
    <EventTrigger RoutedEvent="Button.PreviewDrop">
        <StopStoryboard BeginStoryboardName="TextBeginStoryBoard" />
    </EventTrigger>
</DataTemplate.Triggers>