コード例 #1
0
        private void AnimationCommandExtension_BindingContextChanged(object sender, EventArgs e)
        {
            var bo = (BindableObject)sender;

            try
            {
                //Command wrap
                var command = new Command(async() =>
                {
                    var control         = (View)((GestureRecognizer)sender).Parent;
                    var animationToPlay = StartAnimation ?? new DefaultAnimation();
                    try
                    {
                        if (control != null)
                        {
                            await animationToPlay.Play(control);
                        }
                    }
                    catch
                    {
                        Debug.WriteLine($"{nameof(AnimationCommandExtension)}.StartAnimation Exception");
                    }

                    try
                    {
                        var baseCommand = (ICommand)MarkupExtensionHelper.ExtractMember(bo, (Binding)Binding);
                        if (baseCommand != null && baseCommand.CanExecute(_parameter))
                        {
                            baseCommand.Execute(_parameter);
                        }
                    }
                    catch (Exception exception)
                    {
                        Debug.WriteLine(exception.Message);
                    }

                    try
                    {
                        if (EndAnimation != null && control != null)
                        {
                            await EndAnimation.Play(control);
                        }
                    }
                    catch
                    {
                        Debug.WriteLine($"{nameof(AnimationCommandExtension)}.EndAnimation Exception");
                    }
                });

                bo.SetValue(_property, command);
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
                bo.SetValue(_property, null);
            }
        }
コード例 #2
0
 private void UpdateProperty(CultureInfo culture)
 {
     _cultureInfo = culture;
     if (!string.IsNullOrEmpty(ResourceKey))
     {
         _bo.SetValue(_property, GetStringFormatValue(GetTranslation(ResourceKey)));
     }
     else
     {
         _bo.SetValue(_property,
                      GetStringFormatValue(
                          GetTranslation((string)MarkupExtensionHelper.ExtractMember(_bo, (Binding)Binding))));
     }
 }
コード例 #3
0
        private void LocalizeExtension_BindingContextChanged(object sender, EventArgs e)
        {
            var bo = (BindableObject)sender;

            try
            {
                //EM: BUG_FIX -> this code is bug_fixing can we see to only UWP
                //When working with for example ListView, UWP first sets parent
                //BindingContext and then assigns the true BindingContext for ListItem.
                //The solution for the fix for the _bug is to wait for the right binding context.
                bo.SetValue(_property,
                            GetStringFormatValue(
                                GetTranslation((string)MarkupExtensionHelper.ExtractMember(bo, (Binding)Binding))));
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
                bo.SetValue(_property, null);
            }
        }