Why can't I put a setter inside an event trigger

I was trying to add a visual feed back for a list box that supports drag and drop. It looks like I should be able to add some setters to the EventSetter and do this. However, eventsetters do not support setters. Do I really need to make a storyboard to implement this behavior?

What is Microsoft for this?

   <Style TargetType="{x:Type ListBox}">
        <Style.Triggers>
             <EventTrigger RoutedEvent="DragEnter">
                 <!--WHy Can't i Add seters here? e.g.
                <Setter Property="ForeColor" Value="Red"> 
                -->
            </EventTrigger>
        </Style.Triggers>
    </Style>
+3
source share
4 answers

, , . " " , , - , .

, , , " IsDragOver?"

+7

, - ? sorta-, VS , , . , SetterAction , .

<TextBox Text="ListBox" >
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="DragEnter" >
            <behavior:SetterAction Property="ListBox.ForeColor" Value="Red"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</TextBox>

public class SetterAction : TargetedTriggerAction<FrameworkElement>
{       
    public DependencyProperty Property { get; set; }
    public Object Value { get; set; }   


    protected override void Invoke(object parameter)
    {                 
        AssociatedObject.SetValue(Property, Value);       
    }
}
+3

eventtriggers. . , - . , .

WPF XAML?

+1
+1

Source: https://habr.com/ru/post/1795908/


All Articles