Skip to content

Commit

Permalink
Handles deleting selected item
Browse files Browse the repository at this point in the history
  • Loading branch information
haavamoa committed Nov 18, 2019
1 parent 432df13 commit afdf730
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ public Color SelectedColor
/// to set an initial value.
/// This is a bindable property
/// <remarks>Setting this will trigger <see cref="SelectedItemChangedCommand" /></remarks>
/// <remarks>Can be set to null if you delete the item that you have selected</remarks>
/// </summary>
public object SelectedItem
public object? SelectedItem
{
get => GetValue(SelectedItemProperty);
set => SetValue(SelectedItemProperty, value);
Expand Down Expand Up @@ -267,6 +268,10 @@ private void Initialize(IEnumerable newItems)
{
selectedRadioButton.IsSelected = true;
}
else
{
SelectedItem = null;
}
}
}

Expand Down Expand Up @@ -320,6 +325,7 @@ private BoxView CreateSeparator()
private static void OnIsSelectedPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
{
if (!(bindable is RadioButtonGroup radioButtonGroup)) return;
if (newvalue == null) return;

var selectedRadioButton = radioButtonGroup.m_radioButtons.SingleOrDefault(radioButton => radioButton.Identifier == newvalue);
var unSelectedRadioButton = radioButtonGroup.m_radioButtons.SingleOrDefault(radioButton => radioButton.Identifier == oldvalue);
Expand Down

0 comments on commit afdf730

Please sign in to comment.