I had a dictionary.xaml where I defined the path specified here but I was having compilation error (see error below).
As I want to reuse it in other places, @Clemens suggested me to put it in an WPF UserControl, so I did it but I continue having below error, RoutedEvent Loaded is not recognized.
<UserControl x:Class="my.UI.UC.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://chemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="200">
<Grid>
<Path x:Name="SpinnerPath" Data="M100,10 A90,90 0 0 1 190,100"
Width="24" Height="24"
Stroke="Green" StrokeThickness="20"
StrokeStartLineCap="Round" StrokeEndLineCap="Round"
RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<RotateTransform />
</Path.RenderTransform>
<Path.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard TargetProperty="RenderTransform.Angle">
<DoubleAnimation By="360"
Duration="0:0:1"
RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Path.Triggers>
</Path>
</Grid>
</UserControl>
The compiler throws a compilation error:
XDG0012 The member "Loaded" is not recognized or not accessible
Am I missing a reference to some namespace in my dictionary? If so, what namespace?
You have to keep the size of the Path, otherwise Data and StrokeThickness would not fit.
Put the Path in a Viewbox, and set the Width and Height of the UserControl.
<UserControl x:Class="my.UI.UC.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="24" Height="24">
<Viewbox>
<Path Data="M100,10 A90,90 0 0 1 190,100"
Width="200" Height="200" Stretch="None"
Stroke="Green" StrokeThickness="20"
StrokeStartLineCap="Round" StrokeEndLineCap="Round"
RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<RotateTransform />
</Path.RenderTransform>
<Path.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard Name="LoadedStoryboard">
<Storyboard TargetProperty="RenderTransform.Angle">
<DoubleAnimation By="360" Duration="0:0:1"
RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="Unloaded">
<StopStoryboard BeginStoryboardName="LoadedStoryboard"/>
</EventTrigger>
</Path.Triggers>
</Path>
</Viewbox>
</UserControl>