I'm trying to create a simple animation in a UWP user control, but I'm running into the error Cannot Resolve TargetName. The code is really simple and I feel like I am overlooking something obvious, but I can't figure it out.
XAML
<UserControl
...
x:Name="ManipulationMediaViewerControl"
...
>
<UserControl.Resources>
<Storyboard x:Name="ZoomAnimation">
<DoubleAnimation Duration="0:0:0.25" To="4" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="ViewboxHost" d:IsOptimized="True"/>
<DoubleAnimation Duration="0:0:0.25" To="4" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="ViewboxHost" d:IsOptimized="True"/>
</Storyboard>
</UserControl.Resources>
<Grid>
<Viewbox x:Name="ViewboxHost"
ManipulationMode="All"
Width="{Binding ElementName=ManipulationMediaViewerControl, Path=ActualWidth}"
Height="{Binding ElementName=ManipulationMediaViewerControl, Path=ActualHeight}">
<Viewbox.RenderTransform>
<CompositeTransform CenterX="0.5" CenterY="0.5" />
</Viewbox.RenderTransform>
<ContentPresenter />
</Viewbox>
</Grid>
</UserControl>
Code
using Windows.UI.Xaml.Controls;
namespace ManipulationMediaViewer
{
public sealed partial class ManipulationMediaViewer : UserControl
{
public ManipulationMediaViewer()
{
this.InitializeComponent();
}
public void ZoomToFactor()
{
ZoomAnimation.Begin(); // Breaks here
}
}
}
So my problem is when I try to start ZoomAninmation.Begin();
, I get the exception:
WinRT information: Cannot resolve TargetName ViewboxHost. Additional information: No installed components were detected.
I have this code in a very similar situation in different project that seems to work fine (it is outside of a user control). When this didn't work I deleted the code and created the storyboard through the Blend UI, but it resulted in the same code. Any help is appreciated!
Thanks!
x:Name="ViewboxHost"
to<CompositeTransform x:Name="ViewboxHost" CenterX="0.5" CenterY="0.5" />
– Chris W.