This is a migrated thread and some comments may be shown as answers.

Finding control in edit template

2 Answers 128 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 18 Apr 2011, 06:00 AM
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 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 18 Apr 2011, 01:08 PM
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
0
Pavel Pavlov
Telerik team
answered on 18 Apr 2011, 01:08 PM
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
Tags
DataForm
Asked by
Edward
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or