Inheriting from AnimationTimeLine in ManagedSDK
Hi!
I wanted to animate grid column width (which is of type GridLength) from * to 2*. After doing some research I've come to the conclusion that making a custom GridLengthAnimation is probably going to be the best for my use case. I've followed the WPF tutorial here and made my own class inheriting from AnimationTimeLine. However in Noesis the fields/methods CreateInstanceCore, TargetPropertyType and GetCurrentValue that I need to override are not virtual so this approach doesn't work.
Is there some other way I could create my own AnimationTimeLine class or smoothly animate GridLength in Noesis right now?
I wanted to animate grid column width (which is of type GridLength) from * to 2*. After doing some research I've come to the conclusion that making a custom GridLengthAnimation is probably going to be the best for my use case. I've followed the WPF tutorial here and made my own class inheriting from AnimationTimeLine. However in Noesis the fields/methods CreateInstanceCore, TargetPropertyType and GetCurrentValue that I need to override are not virtual so this approach doesn't work.
Is there some other way I could create my own AnimationTimeLine class or smoothly animate GridLength in Noesis right now?
-
-
sfernandez
Site Admin
- Posts: 2783
- Joined:
Re: Inheriting from AnimationTimeLine in ManagedSDK
Inheriting from AnimationTimeline is not supported yet in C#, could you please report it in our bugtracker?
In the meantime you can animate instead an attached property that updates the column width on the property changed callback:
In the meantime you can animate instead an attached property that updates the column width on the property changed callback:
Code: Select all
public static class GridHelper
{
public static float GetColumnWidth(ColumnDefinition def)
{
return (float)def.GetValue(ColumnWidthProperty);
}
public static void SetColumnWidth(ColumnDefinition def, float value)
{
def.SetValue(ColumnWidthProperty, value);
}
public static readonly DependencyProperty ColumnWidthProperty = DependencyProperty.RegisterAttached(
"ColumnWidth", typeof(float), typeof(GridHelper), new PropertyMetadata(1.0f, OnColumnWidthChanged));
private static void OnColumnWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
{
ColumnDefinition def = d as ColumnDefinition;
if (def != null) def.Width = new GridLength((float)args.NewValue, GridUnitType.Star);
}
}
Code: Select all
<DoubleAnimation From="1" To="2" Duration="0:0:1"
Storyboard.TargetName="col"
Storyboard.TargetProperty="(local:GridHelper.ColumnWidth)"/>
...
<Grid>
<Grid.ColumnDefintions>
<ColumnDefinition x:Name="col"/>
<ColumnDefinition/>
</Grid.ColumnDefintions>
Re: Inheriting from AnimationTimeLine in ManagedSDK
Alright, I've added it to the issue tracker (#2260)
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests