Hi,
I'm trying to get an animation storyboard to trigger when the Window Visibility is changed. I tried the following code but receive an error i.e. Triggers collection members must be of type EventTrigger. Also tried searching for answers but nothing.
Not sure why I get the error and what I need to do to get the intended result? Any help would be appreciated - Thanks!
Here is my simple test code. It has a Main Window with a Button to make the second BalloonWindow Visible.
Main Window VB code:
Class MainWindow
Dim myBalloonWindow As New BalloonWindow
Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
myBalloonWindow.Owner = Me
End Sub
Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
myBalloonWindow.Visibility = Visibility.Visible
End Sub
End Class
Main Window XAML:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BalloonWpfApp"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
<Button Height="40" Width="100" Click="Button_Click">Show Balloon</Button>
</Grid>
</Window>
Balloon Window XAML:
<Window x:Class="BalloonWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BalloonWpfApp"
mc:Ignorable="d"
Title="BalloonWindow" AllowsTransparency="True" WindowStyle="None" Background="Transparent" SizeToContent="WidthAndHeight">
<Window.Triggers>
<!-- Window Visibility Property Trigger Here e.g. <Trigger Property="Visibility" Value="Visible" /> results in error-->
</Window.Triggers>
<Grid Margin="15,18,5,5">
<Path Stroke="DarkGray" StrokeThickness="1" Fill="LightYellow">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="20,0" IsClosed="True">
<LineSegment Point="35,20"/>
<LineSegment Point="285,20"/>
<ArcSegment Point="290,25" Size="5,5" SweepDirection="Clockwise"/>
<LineSegment Point="290,80"/>
<ArcSegment Point="285,85" Size="5,5" SweepDirection="Clockwise"/>
<LineSegment Point="5,85"/>
<ArcSegment Point="0,80" Size="5,5" SweepDirection="Clockwise"/>
<LineSegment Point="0,25"/>
<ArcSegment Point="5,20" Size="5,5" SweepDirection="Clockwise"/>
<LineSegment Point="20,20"/>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
<Path.Effect>
<DropShadowEffect Color="Black" ShadowDepth="4" Opacity="0.6"></DropShadowEffect>
</Path.Effect>
</Path>
</Grid>
</Window>