Exemplo n.º 1
0
        private void RunStoryboard(object sender, DualParameterEventArgs<string, Action> e)
        {
            try
            {
                var storyboardName = e.Parameter1;
                var completedAction = e.Parameter2;

                if (!string.IsNullOrEmpty(e.Parameter1))
                {
                    try
                    {

                        var sb = FindName(storyboardName) as Storyboard;
                        if (sb == null) return;
                        if (completedAction != null)
                        {
#if !NETFX_CORE
                            EventHandler eventHandler = null;
#else
                            EventHandler<object> eventHandler = null;
#endif
                            eventHandler = (s, es) =>
                            {
                                completedAction();
                                // ReSharper disable AccessToModifiedClosure
                                sb.Completed -= eventHandler;
                                // ReSharper restore AccessToModifiedClosure
                            };
                            sb.Completed += eventHandler;
                        }
                        sb.Begin();

                    }
                    // ReSharper disable EmptyGeneralCatchClause
                    catch
                    // ReSharper restore EmptyGeneralCatchClause
                    {
                    }
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
            }

        }
Exemplo n.º 2
0
        private void ViewModelStateChanged(object sender, DualParameterEventArgs<string, bool> e)
        {
            try
            {
                //var controlName = e.Parameter1;
                var stateName = e.Parameter1;
                var useTransitions = e.Parameter2;

                // Locate the control to change state of (use this Page if controlNAme is null)
                Control control = this;
                // ReSharper disable AssignNullToNotNullAttribute
                VisualStateManager.GoToState(control, stateName, useTransitions);
                // ReSharper restore AssignNullToNotNullAttribute
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
            }

        }