Note that there are some explanatory texts on larger screens.

plurals
  1. PODataTrigger that doesn't undo itself when condition no longer met
    text
    copied!<p>Is there a way to do something like the following?</p> <pre><code>&lt;Style TargetType="{x:Type: TreeViewItem}"&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="~Complex Binding~" Value="True" DoNotUnset="True"&gt; &lt;Setter Property="IsExpanded" Value="True"/&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; </code></pre> <p>What I basically would like is this to be a "No Undo DataTrigger" if you will. When the Value is no longer "True" I don't want it to set "IsExpanded" back to its previous value.</p> <p>Here is my attempt to do this using enter actions but this also has problems.</p> <pre><code>&lt;Style TargetType="{x:Type: TreeViewItem}"&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="~Complex Binding~" Value="True"&gt; &lt;DataTrigger.EnterActions&gt; &lt;BeginStoryboard&gt; &lt;BeginStoryboard.Storyboard&gt; &lt;Storyboard&gt; &lt;BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(IsExpanded)" Duration="00:00:01" FillBehavior="Stop"&gt; &lt;BooleanKeyFrameCollection&gt; &lt;DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="True"/&gt; &lt;/BooleanKeyFrameCollection&gt; &lt;/BooleanAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard.Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/DataTrigger.EnterActions&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; </code></pre> <p>First this is insanely verbose but secondly this only works for the duration of the BooleanAnimationUsingKeyFrames. If I change the FillBehavior to "HoldEnd" then it looks correct but now the user can no longer un-expand the treeviewitem by clicks (though oddly enough they still can by using the keyboard). </p> <p>For those who are wondering: yes I'm trying to expand all items in a tree view by binding because I don't want to build a recursive ItemsGenerator.GetItemContainerFromIndex(i) loop. I'd still like to use a similar "No Undo Datatigger" in other areas of my code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload