While reading about DataTrigger on MSDN, it says
Represents a trigger that applies property values or performs actions when the bound data meets a specified condition.
It means
When a trigger is true it changes the value to the desired value.
But, can this be inferred?
When it is no longer true it returns the value to the previous value.
How I came to this conclusion
I did this
<Style x:Key="fd" TargetType="SomeControl">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Button Content="Foo" x:Name="mybutton">
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FooProperty}"
Value="Collapsed">
<Setter Property="IsEnabled" Value="False" TargetName="mybutton"/>
<Setter Property="Opacity" Value="0.5" TargetName="mybutton"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
When FooProperty becomes collapsed it changes mybutton’s IsEnabled to False and Opacity to 0.5
Now when FooProperty becomes visible it changes mybutton’s IsEnabled to True and Opacity to 1 even though I have not written any trigger for reverting back to previous values.
Is this an inbuilt feature of DataTrigger to revert back to previous value When it is no longer true?
If yes, is there any Microsoft/MSDN doc to prove this?
What you are telling, is correct.
As for actual doc to prove this,
search from here:
http://msdn.microsoft.com/en-us/library/ms745683.aspx
http://msdn.microsoft.com/en-us/library/system.windows.trigger.aspx
“Remarks section”
good luck 🙂