1
votes

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!

1
Move x:Name="ViewboxHost" to <CompositeTransform x:Name="ViewboxHost" CenterX="0.5" CenterY="0.5" />Chris W.
I believe you need to reference the control itself, not a component of the control as described hereNolan Blew
Oh that's definitely not correct, I do it all the time, but I also have a bad habit of speeding through questions not paying enough attention. I'll swing back and actually peak in a minute, sorry about that.Chris W.
Ok cool. I'm looking into it and I'm not sure if it's related, but it seems like the ContentPresenter ignores the RenderTransform of the ViewBox. That may be another question thoughNolan Blew
Have you tried to clean and rebuild your code ? I've tested your code on my side and cannot reproduce your issue.Vincent

1 Answers

0
votes

I had the same issue in Visual Studio 2017. I ended up compiling the usercontrol in its own uwp dll and adding it to my new project as reference. The issue went away after dowing that.