動畫我試圖找出如何觸發從我的視圖模型動畫在我的MVVM Xamarin窗體使用MVVM光框架應用程序沒有崩潰我的應用程序。觸發按鈕按下
我已經瞭解到,動畫不會在視圖模型屬於,所以我搬到這個邏輯視圖。
當按下一個按鈕(在我的視圖模型綁定到的命令)將消息發送從我的視圖模型到我的視圖觸發動畫。
視圖模型代碼:
public class GamePageViewModel : ViewModelBase
{
private readonly IDialogService _dialogService;
public ICommand NextRoundCommand
{
get
{
return new RelayCommand(() =>
{
NextButtonEnabled = false;
_game.MoveToNextRound();
UpdateOnScreenText();
NextButtonEnabled = true;
},()=> false);
}
}
private bool _nextButtonEnabled = false;
public bool NextButtonEnabled
{
get { return _nextButtonEnabled; }
set
{
_nextButtonEnabled = value;
RaisePropertyChanged(()=>NextButtonEnabled);
}
}
private void UpdateOnScreenText()
{
Messenger.Default.Send(new StartEnlargeAnimationMessage());
Item1Text = _game.CurrentRound.OpenCards[0].Name;
}
}
在我的XAML視圖背後的代碼,我有一個執行動畫的方法。
查看代碼:
public partial class GamePage : ContentPage
{
public GamePage(GamePageViewModel gamePageViewModel)
{
BindingContext = gamePageViewModel;
InitializeComponent();
Messenger.Default.Register<StartEnlargeAnimationMessage>(this, PlayEnlargeAnimation);
}
//private bool playingAnimation = false;
private async void PlayEnlargeAnimation(StartEnlargeAnimationMessage message)
{
await RoundLabel.ScaleTo(2, 500, Easing.CubicIn);
await RoundLabel.ScaleTo(1, 500, Easing.CubicIn);
}
這工作有點。
的問題是,當用戶點擊該按鈕兩次(快速,主動動畫中)我得到一個錯誤「試圖當它已經完成了任務過渡到最終狀態」。
這個問題似乎是很多個月的已知問題,但還沒有固定的(https://bugzilla.xamarin.com/show_bug.cgi?id=41016)。
正如在這個錯誤報告我試圖解決這個辦法的意見建議是儘量隱藏/關閉按鈕,但尚未發現這樣做的全成的方式。
我也試着同步調用動畫。
如果您有任何關於如何解決這種情況的見解,將不勝感激。
我(還小),代碼庫可以在這裏找到:https://github.com/sjorsmiltenburg/Cyclades.Shuffler/tree/develop