5

When I try to start my app with this code it throws an exception saying error text cannot be found.

<Button> <Button.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard> <DoubleAnimation Duration="0:0:05" To="1" From="0" Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="Opacity" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> </Button> 

Seems like something wrong with the routed event property. What will fix this exception.

2
  • I had left one comment, then realized I didn't pay attention. That way of doing it like you're used to in WPF isn't accepted in UWP. You'll either need to do interaction triggers or just do a quick Storyboard.Begin() method to call it via Click="MethodName" on the button with a one liner of codebehind. If I wasn't in a rush I'd pop you an example but I'm sure someone will read this and grab the points. :) Commented Apr 26, 2016 at 19:12
  • I was hoping for no code behind lol. I'm trying to do interaction triggers but I haven't figured out how to add a story board to it. it complains when I do. Commented Apr 26, 2016 at 19:19

1 Answer 1

4

I think the best way is to use a Behavior. It's their purpose to extend the functions of basic controls combined with reusability. You can see a snippet right over here on Windows blog (and as I see, it's a part of the framework in Namespace: Microsoft.Xaml.Interactions.Core Assembly: Microsoft.Xaml.Interactions in Microsoft.Xaml.Interactions.dll).

<Button x:Name="button"> <Interactivity:Interaction.Behaviors> <Core:EventTriggerBehavior EventName="Click"> <Media:ControlStoryboardAction Storyboard="storyboard1"/> </Core:EventTriggerBehavior> </Interactivity:Interaction.Behaviors> </Button> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.