Saturday, 24 August 2013

Windows Phone EventTrigger not working

Windows Phone EventTrigger not working

I have a DataTemplate which is used to populate a longlistselector. In
this DataTemplate are 2 rows. Row 1 contains a button, when pressed it
should slide open row 2. The problem is when I run the app I get an
UnhandledException.
Here is the DataTemplate:
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- 1st ROW -->
<Border Background="Red" HorizontalAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="Test Item" FontSize="42" />
<Button Content="v" Grid.Column="1">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Tap">
<BeginStoryboard>
<Storyboard x:Name="myBoard"
TargetProperty="Border.Height"
TargetName="Slider">
<DoubleAnimation From="0" To="60"
Duration="0:0:2" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</Grid>
</Border>
<!-- 2nd ROW -->
<Border x:Name="Slider" Grid.Row="1" Background="Green"
HorizontalAlignment="Stretch" Height="0">
<TextBlock Text="Slider" FontSize="42" />
</Border>
</Grid>
</DataTemplate>

No comments:

Post a Comment