[Unity] - ValueConverter and DoubleAnimation
I'm trying to do a simple storyboard where the animation "To" should use Binding towards a ContentControl.ActualHeight but with the value negated using a converter.
However I'm having trouble getting it to work.
I either get the below exception when using doubles
I'm probably doing something stupid but hoping someone here has an idea on how to solve this or can point me in the right direction?
However I'm having trouble getting it to work.
I either get the below exception when using doubles
Or when using floatException: System.InvalidOperationException: Converter.Convert() expects Nullable`1 and Double is returned
at Noesis.Extend.ConverterConvert (IntPtr unityType, IntPtr cPtr, IntPtr valPtr, IntPtr typePtr, IntPtr paramPtr) [0x0006d]
Exception: '-0' (Boxed<Float32>) is not a valid value for property 'DoubleAnimation.To'
Code: Select all
public class NegateDoubleConverter : IValueConverter
{
public object Convert (object value, Type targetType, object parameter, CultureInfo culture)
{
double val = System.Convert.ToDouble(value);
return -val;
}
public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException ();
}
}
Code: Select all
<Storyboard x:Key="OnTitleAreaInvisible">
<DoubleAnimation Storyboard.TargetName="TitleArea"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"
From="0" To="{Binding ElementName=TitleArea, Path=ActualHeight, Converter={StaticResource negateDoubleConverter}}" Duration="0:0:0.5"/>
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: [Unity] - ValueConverter and DoubleAnimation
Hi,
There is a bug when using a Converter in the Binding and the target property is a Nullable type. We will fix it for the next release. Sorry for the inconvenience.
Apart from that, you should use float because as our API uses float instead of double: ActualWidth property is float, the DoubleAnimation animates float values, etc.
There is a bug when using a Converter in the Binding and the target property is a Nullable type. We will fix it for the next release. Sorry for the inconvenience.
Apart from that, you should use float because as our API uses float instead of double: ActualWidth property is float, the DoubleAnimation animates float values, etc.
Who is online
Users browsing this forum: Ahrefs [Bot], dstewart and 6 guests