Doubleanimation bind To property dynamically in Silverlight:

Doubleanimation bind To property dynamically in Silverlight:


  • Some time we may not know the To value for the Doubleanimation property at design time,For example in my case i have an datagrid, i'm going to bind that datagrid height as To property,but i bind the itemSource for the datagrid dynamically.
  • So in that situation i get the height of the datagrid after Binding the dataSource using C#, and i assigned the height value to Datagrid tag property, And finally i can bind that tag property to the Doubleanimation 'To' property 



xaml code:

<Storyboard x:Name="animation" Storyboard.TargetProperty="(Canvas.Top)" RepeatBehavior="Forever">
<DoubleAnimation Storyboard.TargetName="YourControlName" From="20" To="{Binding Tag, ElementName=DataGridName}" Duration="0:0:15"  /> 
</Storyboard>


C# code:

After Binding the item source use the following code

DataGridName.UpdateLayout();
DataGridName.Tag = -dgNewsAndAlerts.ActualHeight;    //-value for To property

Change the animation speed using C#:

   animation.SpeedRatio = 1; //apply some logic and give that value here(Value b\w 0 to 1)

Example Program for Siverlight  Animation:

http://sharepointdeveloperblog.blogspot.in/2013/10/silverlight-canvas-example-in.html

Comments

Popular posts from this blog

Upload Single/Multiple file by using the REST API and jQuery SharePoint 2013

A type named 'SP.Data. could not be resolved by the model error

Add content type to SharePoint List/Library using REST API