I have an Apple Spinner User Control in my WPF application. Spinner created by following link. I have placed this Spinner in a Popup and show/hide based on condition. I am using MVVM and Prism.
Issue : I open Popup from code behind, and spinner does not animate at all. It shows though (within Popup), but it is frozen.
In case I remove spinner from Popup, animation works fine and runs smoothly.
The UC_SpinnerPopup.xaml code:
<UserControl x:Class="SEM.UI.Views.UC_SpinnerPopup"
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://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SEM.UI.Views"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Interactivity;assembly=Microsoft.Practices.Prism.Interactivity"
mc:Ignorable="d"
Height="{Binding Source={x:Static SystemParameters.PrimaryScreenHeight}}"
Width="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}}">
<Grid>
<Popup Name="SpinPopUp" HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" Height="500"
Placement="Center" IsOpen="{Binding Path=IsSpinPopUpOpen, Mode=TwoWay}" AllowsTransparency="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Opened">
<prism:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource
AncestorType={x:Type UserControl}, Mode=FindAncestor}}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid x:Name="LayoutRoot" Background="Transparent" >
<Grid Margin="100,0" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.15*"/>
</Grid.ColumnDefinitions>
<local:UC_AppleSpinner Margin="10" HorizontalAlignment="Center" VerticalAlignment="Top" Grid.Column="2"/>
</Grid>
</Grid>
</Popup>
</Grid>
View Model code SpinnerPopupViewModel.cs:
private bool _isSpinPopupOpen;
protected readonly IEventAggregator _eventAggregator;
public bool IsSpinPopUpOpen
{
get
{
return _isSpinPopupOpen;
}
set
{
SetProperty(ref _isSpinPopupOpen, value);
}
}
public SpinnerPopupViewModel(IEventAggregator eventAggregator)
{
this._eventAggregator = eventAggregator;
this._eventAggregator.GetEvent<SpinnerPopupEvent>()
.Subscribe((item) => { IsSpinPopUpOpen = item; });
}
The property is set based on condition in ViewModel and there is no issue in the same.
Main issue is freezing of animation within Popup.