Exemplo n.º 1
0
        private static void labelMarginPropertyPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            BindableRadioGroupView target = bindable as BindableRadioGroupView;

            foreach (BindableRadioButton btn in target.radioButtons)
            {
                btn.LabelMargin = newValue.ToString();
            }
        }
Exemplo n.º 2
0
        private static void fontAttributesPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            BindableRadioGroupView target = bindable as BindableRadioGroupView;

            foreach (BindableRadioButton btn in target.radioButtons)
            {
                btn.FontAttributes = newValue.ToString();
            }
        }
Exemplo n.º 3
0
        private static void CheckBoxColorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            BindableRadioGroupView target = bindable as BindableRadioGroupView;

            foreach (BindableRadioButton btn in target.radioButtons)
            {
                btn.CheckBoxColor = (Xamarin.Forms.Color)newValue;
            }
        }
Exemplo n.º 4
0
        private static void fontSizePropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            BindableRadioGroupView target = bindable as BindableRadioGroupView;

            if (double.TryParse(newValue.ToString(), out double tmp))
            {
                foreach (BindableRadioButton btn in target.radioButtons)
                {
                    btn.FontSize = tmp;
                }
            }
        }
Exemplo n.º 5
0
        private static void selectedNoPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            BindableRadioGroupView group = bindable as BindableRadioGroupView;

            if (oldValue == null && group.radioButtons != null)
            {
                int no;
                if (int.TryParse(newValue.ToString(), out no) && no > 0)
                {
                    int index = no - 1;
                    group.radioButtons[index].IsChecked = true;
                }
            }
        }
Exemplo n.º 6
0
        private static void displayPathChanged(BindableObject bindable, object oldValue, object newValue)
        {
            BindableRadioGroupView target = bindable as BindableRadioGroupView;

            if (target.radioButtons == null)
            {
                return;
            }

            foreach (var item in target.radioButtons)
            {
                string displayPath = newValue.ToString();
                item.SetTextBinding(displayPath);
            }
        }
Exemplo n.º 7
0
        private static void ItemsSourcePropertyChanged(BindableObject bindable, IEnumerable oldValue, IEnumerable newValue)
        {
            BindableRadioGroupView group = bindable as BindableRadioGroupView;

            group.radioButtons.Clear();
            group.Children.Clear(); // StackLayout

            if (newValue != null)
            {
                int radIndex = 0;
                foreach (var item in newValue)
                {
                    var rad = new BindableRadioButton();
                    rad.Id             = radIndex;
                    rad.BindingContext = item;

                    rad.CheckedChanged += group.OnCheckedChanged;

                    group.radioButtons.Add(rad);
                    group.Children.Add(rad); // StackLayout

                    radIndex++;
                }

                sSetGroupViewUIProperty(group);

                #region 设置默认选中项

                if (group.SelectedText != null)
                {
                    var match = group.radioButtons.FirstOrDefault(i => i.Text == group.SelectedText.ToString());
                    if (match != null)
                    {
                        match.IsChecked = true;
                    }
                }
                else if (int.TryParse(group.SelectedNo.ToString(), out int no) && no > 0)
                {
                    if (no >= 1)
                    {
                        int index = no - 1;
                        group.radioButtons[index].IsChecked = true;
                    }
                }

                #endregion
            }
        }
Exemplo n.º 8
0
        private static void selectedTextPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            BindableRadioGroupView group = bindable as BindableRadioGroupView;

            if (oldValue == null && group.radioButtons != null)
            {
                foreach (BindableRadioButton item in group.radioButtons)
                {
                    if (item.Text == newValue.ToString())
                    {
                        item.IsChecked = true;
                        break;
                    }
                }
            }
        }
Exemplo n.º 9
0
        private static void sSetGroupViewUIProperty(BindableRadioGroupView view)
        {
            if (view.radioButtons == null || view.radioButtons.Count <= 0)
            {
                return;
            }

            foreach (var rad in view.radioButtons)
            {
                if (view.DisplayPath.IsNullOrWhiteSpace() == false)
                {
                    rad.SetTextBinding(view.DisplayPath);
                }

                if (view.CheckBoxColor != Xamarin.Forms.Color.Transparent)
                {
                    rad.CheckBoxColor = view.CheckBoxColor;
                }

                if (view.TextColor != Xamarin.Forms.Color.Transparent)
                {
                    rad.TextColor = view.TextColor;
                }

                if (view.CheckBoxMargin.IsNullOrWhiteSpace() == false)
                {
                    rad.CheckBoxMargin = view.CheckBoxMargin;
                }

                if (view.LabelMargin.IsNullOrWhiteSpace() == false)
                {
                    rad.LabelMargin = view.LabelMargin;
                }

                if (view.FontAttributes.IsNullOrWhiteSpace() == false)
                {
                    rad.FontAttributes = view.FontAttributes;
                }

                if (view.FontSize > 0)
                {
                    rad.FontSize = view.FontSize;
                }
            }
        }