Example #1
0
        private static void OnFontSizeChanged(BindableObject bindable, object oldValue, object newValue)
        {
            if (GetCancelEvents(bindable))
            {
                return;
            }

            SetCancelEvents(bindable, true);

            var values         = bindable.GetValues(FontFamilyProperty, FontAttributesProperty);
            var fontSize       = (double)newValue;
            var fontAttributes = (FontAttributes)values[1];
            var fontFamily     = (string)values[0];

            if (fontFamily != null)
            {
                bindable.SetValue(FontProperty, Font.OfSize(fontFamily, fontSize).WithAttributes(fontAttributes));
            }
            else
            {
                bindable.SetValue(FontProperty, Font.SystemFontOfSize(fontSize, fontAttributes));
            }

            SetCancelEvents(bindable, false);
            ((IFontElement)bindable).OnFontSizeChanged((double)oldValue, (double)newValue);
        }