This repository was archived by the owner on Nov 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
DataTriggerBehavior won't fire actions on initial state right after attaching to the owner #80
Copy link
Copy link
Open
Labels
Description
DataTriggerBehavior currently executes actions when specific condition is executed as true, as expected.
But DataTriggerBehavior does not execute anything when it was attached and initial condition is true as well.
Consider example below. Trigger should execute actions when binding results in value 50. But if 50 is a default value, trigger won't see that, until you change value to 55 and then back to 50.
<UserControl x:Class="BehaviorsTestApplication.Views.Pages.DataTriggerBehaviorView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="using:Avalonia.Xaml.Interactivity"
xmlns:ia="using:Avalonia.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:BehaviorsTestApplication.ViewModels"
x:CompileBindings="True" x:DataType="vm:MainWindowViewModel"
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="450">
<Design.DataContext>
<vm:MainWindowViewModel />
</Design.DataContext>
<Grid RowDefinitions="*,Auto">
<Rectangle Name="DataTriggerRectangle"
Grid.Row="0" Margin="5"
Fill="{DynamicResource BlueBrush}"
Stroke="{DynamicResource GrayBrush}"
StrokeThickness="5">
<i:Interaction.Behaviors>
<ia:DataTriggerBehavior Binding="{Binding #Slider.Value}"
ComparisonCondition="Equal"
Value="50">
<ia:ChangePropertyAction TargetObject="{Binding #DataTriggerRectangle}"
PropertyName="Fill"
Value="{DynamicResource YellowBrush}" />
</ia:DataTriggerBehavior>
</i:Interaction.Behaviors>
</Rectangle>
<StackPanel Grid.Row="1"
Margin="5,0,5,5"
Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock Text="{Binding #Slider.Value}"
VerticalAlignment="Center"
Width="50"
Foreground="{DynamicResource GrayBrush}" />
<Slider Name="Slider" Value="50" Width="400" IsSnapToTickEnabled="True" TickFrequency="1" />
</StackPanel>
</Grid>
</UserControl>
Reactions are currently unavailable