Finding control in edit template

3 posts, 0 answers
  1. Edward
    Edward avatar
    83 posts
    Member since:
    Feb 2011

    Posted 18 Apr 2011 Link to this post

    I have a storyboard and I want to have it animated when the data is loaded.  I couldn't assign the TargetName there since I think control inside datatemplate is not visible to outside.  So I was trying to use FindName to locate the control and do SetTarget in codebehind.  However FindName always return null.  I checked another post here and it said something about in different namespace so FindName won't work.

    What I did is I catch the Loaded event from the control inside DataForm, and assign it to a variable.  Then  I do the SetTarget and Begin in another event (I use DataLoaded in DomainDataSource) to start the animation.  Is there a better way?

    <UserControl.Resources>
            <Storyboard x:Name="myStoryboard">
                <DoubleAnimation
              Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)"
              From="-180.0" To="0.0" Duration="0:0:2"
              AutoReverse="False"/>
            </Storyboard>
    </UserControl.Resources>
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 18 Apr 2011 Link to this post

    Hello Edward,

    As long as your approach is doing the job , it seems as a good one to me.
    An alternative for looking a control inside the temlpate would be to use the ChildrenOfType<T>() extension method . ( in the Telerik.Windows.Controls ) namespace.

    In case you have difficulties with such implementation , you may paste me your template  and let me know which control inside you need manipulated. In return  will provide then some code for you which finds the control on the data loaded event.

    All the best,
    Pavel Pavlov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 18 Apr 2011 Link to this post

    Hello Edward,

    As long as your approach is doing the job , it seems as a good one to me.
    An alternative for looking a control inside the temlpate would be to use the ChildrenOfType<T>() extension method . ( in the Telerik.Windows.Controls ) namespace.

    In case you have difficulties with such implementation , you may paste me your template  and let me know which control inside you need manipulated. In return  will provide then some code for you which finds the control on the data loaded event.

    All the best,
    Pavel Pavlov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top