コード例 #1
0
        private void ElementOnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "Checked":
                Control.IsChecked = Element.Checked;
                break;

            case "TextColor":
                Control.Foreground = new SolidColorBrush(ValueConverters.FormsColorToNative(Element.TextColor));
                break;

            case "FontName":
                if (!string.IsNullOrEmpty(Element.FontName))
                {
                    Control.FontFamily = ValueConverters.StringToFontFamily(Element.FontName);
                }
                break;

            case "FontSize":
                if (Element.FontSize > 0)
                {
                    Control.FontSize = (float)Element.FontSize;
                }
                break;

            case "CheckedText":
            case "UncheckedText":
                break;

            default:
                System.Diagnostics.Debug.WriteLine("Property change for {0} has not been implemented.", e.PropertyName);
                break;
            }
        }
コード例 #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <CheckBox> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                e.OldElement.PropertyChanged -= ElementOnPropertyChanged;
            }

            if (Control == null)
            {
                var checkBox = new NativeCheckBox();
                checkBox.Checked   += checkBox_Checked;
                checkBox.Unchecked += checkBox_Unchecked;

                SetNativeControl(checkBox);
            }

            Control.IsChecked = e.NewElement.Checked;

            Control.Foreground = new SolidColorBrush(ValueConverters.FormsColorToNative(e.NewElement.TextColor));

            if (e.NewElement.FontSize > 0)
            {
                Control.FontSize = (float)e.NewElement.FontSize;
            }

            if (!string.IsNullOrEmpty(e.NewElement.FontName))
            {
                Control.FontFamily = ValueConverters.StringToFontFamily(e.NewElement.FontName);
            }

            Element.CheckedChanged  += CheckedChanged;
            Element.PropertyChanged += ElementOnPropertyChanged;
        }