private static void AdapterViewSelectedItemPositionChanged(AdapterView sender, AttachedMemberChangedEventArgs <int> args) { if (sender.GetBindingMemberValue(AttachedMembers.AdapterView.ScrollToSelectedItem).GetValueOrDefault(true) || sender is Spinner) { sender.SetSelection(args.NewValue); } var adapter = GetAdapter(sender) as IItemsSourceAdapter; if (adapter != null) { sender.SetBindingMemberValue(AttachedMembers.AdapterView.SelectedItem, adapter.GetRawItem(args.NewValue)); } }
private static void SetSelectedIndexAdapterView(AdapterView adapter, int index) { var oldValue = adapter.GetBindingMemberValue(AttachedMembers.AdapterView.ScrollToSelectedItem); if (oldValue != null && !oldValue.Value) { adapter.SetBindingMemberValue(AttachedMembers.AdapterView.SelectedItemPosition, index); } else { adapter.SetBindingMemberValue(AttachedMembers.AdapterView.ScrollToSelectedItem, false); adapter.SetBindingMemberValue(AttachedMembers.AdapterView.SelectedItemPosition, index); adapter.SetBindingMemberValue(AttachedMembers.AdapterView.ScrollToSelectedItem, oldValue); } }