Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 77ab1db

Browse files
authored
Remove ButtonSource API (#9967)
fixes #9948
1 parent 109e616 commit 77ab1db

File tree

3 files changed

+50
-47
lines changed

3 files changed

+50
-47
lines changed

Xamarin.Forms.Controls/CoreGalleryPages/RadioButtonCoreGalleryPage.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,23 @@ protected override void Build(StackLayout stackLayout)
105105

106106
var isCheckedContainer = new ValueViewContainer<RadioButton>(Test.RadioButton.IsChecked, new RadioButton() { IsChecked = true, HorizontalOptions = LayoutOptions.Start }, "IsChecked", value => value.ToString());
107107

108-
var checkedVisualState = new VisualState { Name = "IsChecked" };
109-
checkedVisualState.Setters.Add(new Setter { Property = RadioButton.ButtonSourceProperty, Value = "rb_checked" });
108+
//var checkedVisualState = new VisualState { Name = "IsChecked" };
109+
//checkedVisualState.Setters.Add(new Setter { Property = RadioButton.ButtonSourceProperty, Value = "rb_checked" });
110110

111-
var group = new VisualStateGroup();
112-
group.States.Add(checkedVisualState);
111+
//var group = new VisualStateGroup();
112+
//group.States.Add(checkedVisualState);
113113

114-
var normalVisualState = new VisualState{ Name = "Normal" };
115-
normalVisualState.Setters.Add(new Setter { Property = RadioButton.ButtonSourceProperty, Value = "rb_unchecked" });
116-
group.States.Add(normalVisualState);
114+
//var normalVisualState = new VisualState{ Name = "Normal" };
115+
//normalVisualState.Setters.Add(new Setter { Property = RadioButton.ButtonSourceProperty, Value = "rb_unchecked" });
116+
//group.States.Add(normalVisualState);
117117

118-
var groupList = new VisualStateGroupList();
119-
groupList.Add(group);
118+
//var groupList = new VisualStateGroupList();
119+
//groupList.Add(group);
120120

121-
var rbStateManaged = new RadioButton() { HorizontalOptions = LayoutOptions.Start };
122-
VisualStateManager.SetVisualStateGroups(rbStateManaged, groupList);
121+
//var rbStateManaged = new RadioButton() { HorizontalOptions = LayoutOptions.Start };
122+
//VisualStateManager.SetVisualStateGroups(rbStateManaged, groupList);
123123

124-
var stateManagedContainer = new ValueViewContainer<RadioButton>(Test.RadioButton.ButtonSource, rbStateManaged, "IsChecked", value => value.ToString());
124+
//var stateManagedContainer = new ValueViewContainer<RadioButton>(Test.RadioButton.ButtonSource, rbStateManaged, "IsChecked", value => value.ToString());
125125

126126
Add(borderButtonContainer);
127127
Add(borderRadiusContainer);
@@ -134,7 +134,7 @@ protected override void Build(StackLayout stackLayout)
134134
Add(textColorContainer);
135135
Add(paddingContainer);
136136
Add(isCheckedContainer);
137-
Add(stateManagedContainer);
137+
//Add(stateManagedContainer);
138138
}
139139
}
140140
}

Xamarin.Forms.Core/RadioButton.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ public class RadioButton : Button, IElementConfiguration<RadioButton>
2020
public static readonly BindableProperty GroupNameProperty = BindableProperty.Create(
2121
nameof(GroupName), typeof(string), typeof(RadioButton), null, propertyChanged: (b, o, n) => ((RadioButton)b).OnGroupNamePropertyChanged((string)o, (string)n));
2222

23-
public static readonly BindableProperty ButtonSourceProperty = BindableProperty.Create(
24-
nameof(ButtonSource), typeof(ImageSource), typeof(RadioButton), null);
23+
// TODO Needs implementations beyond Android
24+
//public static readonly BindableProperty ButtonSourceProperty = BindableProperty.Create(
25+
// nameof(ButtonSource), typeof(ImageSource), typeof(RadioButton), null);
2526

2627
public event EventHandler<CheckedChangedEventArgs> CheckedChanged;
2728

@@ -37,11 +38,12 @@ public string GroupName
3738
set { SetValue(GroupNameProperty, value); }
3839
}
3940

40-
public ImageSource ButtonSource
41-
{
42-
get { return (ImageSource)GetValue(ButtonSourceProperty); }
43-
set { SetValue(ButtonSourceProperty, value); }
44-
}
41+
// TODO Needs implementations beyond Android
42+
//public ImageSource ButtonSource
43+
//{
44+
// get { return (ImageSource)GetValue(ButtonSourceProperty); }
45+
// set { SetValue(ButtonSourceProperty, value); }
46+
//}
4547

4648
public RadioButton()
4749
{

Xamarin.Forms.Platform.Android/AppCompat/RadioButtonRenderer.cs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ protected virtual void OnElementChanged(ElementChangedEventArgs<Button> e)
211211
UpdateInputTransparent();
212212
UpdateBackgroundColor();
213213
_buttonLayoutManager?.Update();
214-
UpdateButtonImage(true);
214+
//UpdateButtonImage(true);
215215
UpdateIsChecked();
216216
ElevationHelper.SetElevation(this, e.NewElement);
217217
}
@@ -237,10 +237,10 @@ protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEv
237237
{
238238
UpdateIsChecked();
239239
}
240-
else if (e.PropertyName == RadioButton.ButtonSourceProperty.PropertyName)
241-
{
242-
UpdateButtonImage(false);
243-
}
240+
//else if (e.PropertyName == RadioButton.ButtonSourceProperty.PropertyName)
241+
//{
242+
// UpdateButtonImage(false);
243+
//}
244244

245245
ElementPropertyChanged?.Invoke(this, e);
246246
}
@@ -338,28 +338,29 @@ void UpdateTextColor()
338338
_textColorSwitcher.Value.UpdateTextColor(this, Button.TextColor);
339339
}
340340

341-
void UpdateButtonImage(bool isInitializing)
342-
{
343-
if (Element == null || _isDisposed)
344-
return;
345-
346-
ImageSource buttonSource = ((RadioButton)Element).ButtonSource;
347-
if (buttonSource != null && !buttonSource.IsEmpty)
348-
{
349-
Drawable currButtonImage = Control.ButtonDrawable;
350-
351-
this.ApplyDrawableAsync(RadioButton.ButtonSourceProperty, Context, image =>
352-
{
353-
if (image == currButtonImage)
354-
return;
355-
Control.SetButtonDrawable(image);
356-
357-
Element.InvalidateMeasureNonVirtual(InvalidationTrigger.MeasureChanged);
358-
});
359-
}
360-
else if(!isInitializing)
361-
Control.SetButtonDrawable(null);
362-
}
341+
// TODO Needs implementations beyond Android
342+
//void UpdateButtonImage(bool isInitializing)
343+
//{
344+
// if (Element == null || _isDisposed)
345+
// return;
346+
347+
// ImageSource buttonSource = ((RadioButton)Element).ButtonSource;
348+
// if (buttonSource != null && !buttonSource.IsEmpty)
349+
// {
350+
// Drawable currButtonImage = Control.ButtonDrawable;
351+
352+
// this.ApplyDrawableAsync(RadioButton.ButtonSourceProperty, Context, image =>
353+
// {
354+
// if (image == currButtonImage)
355+
// return;
356+
// Control.SetButtonDrawable(image);
357+
358+
// Element.InvalidateMeasureNonVirtual(InvalidationTrigger.MeasureChanged);
359+
// });
360+
// }
361+
// else if(!isInitializing)
362+
// Control.SetButtonDrawable(null);
363+
//}
363364

364365
void UpdateIsChecked()
365366
{

0 commit comments

Comments
 (0)