Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Bind UserControl to resource
    text
    copied!<p>At the moment, I'm doing some experimentation. My current scenario: I have a StoryBoard to transition between 2 UserControls (for example, it shrinks the current UserControl then grows the other).</p> <p>What I want to do is to have 2 UserControls defined as part of the XAML, with keys of "Current" and "Next". The Current should be bound to the currently viewed UserControl. The Next should be bound before transition, so the StoryBoard knows which element to transition to. Here's where I'm stuck: ENTIRELY using XAML, how would one go about this?</p> <p>I have a simple StoryBoard that is a Resource of the ItemsControl, as well as two UserControl items:</p> <pre><code>&lt;ItemsControl.Resources&gt; &lt;Storyboard x:Key="TransitionStoryboard"&gt; &lt;!-- Shrink this one. --&gt; &lt;DoubleAnimation Storyboard.Target="{Binding Current}" Storyboard.TargetProperty="Width" To="0" Duration="0:0:1"/&gt; &lt;!--Grow the next.--&gt; &lt;DoubleAnimation Storyboard.Target="{Binding Next}" Storyboard.TargetProperty="Width" To="100" BeginTime="0:0:1" Duration="0:0:1"/&gt; &lt;/Storyboard&gt; &lt;UserControl x:Key="Current"/&gt; &lt;UserControl x:Key="Next" Width="0"/&gt; &lt;/ItemsControl.Resources&gt; </code></pre> <p>So, when I define a new UserControl that belongs to the ItemsControl (like this):</p> <pre><code>&lt;my:Control1 x:Name="ControlOne"/&gt; </code></pre> <p>How do I set the "Current" UserControl top be ControlOne? Then, when I want to transition, how do I set one as "Next"? And how can I change these after a trigger?</p> <p>Thanks</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