Note that there are some explanatory texts on larger screens.

plurals
  1. POSIlverlight Generic Template Animat Parent Control Property
    primarykey
    data
    text
    <p>I have a custom control with its template defined in a generic.xaml. It is a two row grid in which the second row can be "retracted into" the first row. </p> <p>However, I found that when I simply animated the height of the second row or the grid to acheive the desired results, the parent of the template (i.e the instance of my custom control) still had the same height. This lead to list boxes with lots of white space in them between each element.</p> <p>I need to just have the animation change the height of the actual containing control, but I don't know how to do this. I can <strong>set</strong> the height easily with somthing like:</p> <pre><code> &lt;Style TargetType="myLib:MyControl"&gt; &lt;!--Default Values--&gt; &lt;Setter Property="Height" Value="100" /&gt; </code></pre> <p>However, when defining an animation, I have no idea what to put in the StoryBoard.TargetName to refer to "this" control:</p> <pre><code> &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="ViewStates"&gt; &lt;VisualState x:Name="Retracted"&gt; &lt;DoubleAnimation Storyboard.TargetName="this?" Storyboard.TargetProperty="Height" To="25" Duration="0" /&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; </code></pre> <p>If I leave that blank I get an error.</p> <p>I figure I can probably create the animation in the code behind for the control, but I'd like to use the state manager instead. </p> <p>I also thought about creating a self referencing dependency property, that that seems a bit off course.</p> <p>Isn't there some kind of binding I could use here?</p> <p>Thanks in advance for any help :)</p> <p>PS - I was able to later get the desired effect in code as such:</p> <pre><code> Storyboard sb = new Storyboard(); DoubleAnimation da = new DoubleAnimation(); da.To = ExtendedHeight; da.Duration = new Duration(TimeSpan.FromMilliseconds(200)); sb.Children.Add(da); Storyboard.SetTarget(da, this); Storyboard.SetTargetProperty(da, new PropertyPath("Height")); sb.Begin(); </code></pre> <p>So I'm still hopeful that a similar markup solution can be done. Gads I'm sure its got to be something obvious I'm missing here.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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