diff --git a/Aurora/Design/Components/TabView/TabView.cs b/Aurora/Design/Components/TabView/TabView.cs index 659e42f..81cbbb2 100644 --- a/Aurora/Design/Components/TabView/TabView.cs +++ b/Aurora/Design/Components/TabView/TabView.cs @@ -153,7 +153,7 @@ namespace Aurora.Design.Components.TabView } } - SetCurrentTab(0, true); + SetCurrentTab(SelectedTabIndex, true); } } @@ -439,7 +439,13 @@ namespace Aurora.Design.Components.TabView #endregion #region SelectedTabIndex - public static readonly BindableProperty SelectedTabIndexProperty = BindableProperty.Create(nameof(SelectedTabIndex), typeof(int), typeof(TabViewControl), 0, propertyChanged: OnSelectedTabIndexChanged); + public static readonly BindableProperty SelectedTabIndexProperty = BindableProperty.Create( + nameof(SelectedTabIndex), + typeof(int), + typeof(TabViewControl), + defaultValue: 0, + defaultBindingMode: BindingMode.TwoWay, + propertyChanged: OnSelectedTabIndexChanged); private static void OnSelectedTabIndexChanged(BindableObject bindable, object oldValue, object newValue) { if (bindable is TabViewControl tabViewControl && tabViewControl.ItemSource != null) @@ -477,14 +483,25 @@ namespace Aurora.Design.Components.TabView if (((position >= 0 && position < ItemSource.Count) || initialRun)) { - if (oldPosition < ItemSource.Count && _mainContainerSL.Children.Count == 2) + if (oldPosition < ItemSource.Count) { - ItemSource[oldPosition].IsCurrent = false; - //Remove second child - _mainContainerSL.Children.RemoveAt(1); + List tabActiveList = ItemSource.Select((TabItem tab, int index) => + { + return index == position; + }) + .ToList(); + + for (int i = 0; i < tabActiveList.Count(); i++) + { + ItemSource[i].IsCurrent = tabActiveList[i]; + } + // Remove second child + if (_mainContainerSL.Children.Count == 2) + { + _mainContainerSL.Children.RemoveAt(1); + } } _mainContainerSL.Children.Add(ItemSource[position].Content); - ItemSource[position].IsCurrent = true; SelectedTabIndex = position; Device.BeginInvokeOnMainThread(async () => await _tabHeadersContainerSv.ScrollToAsync(_headerContainerGrid.Children[position], ScrollToPosition.MakeVisible, false)); diff --git a/Aurora/Design/Views/Party/PartyView.xaml b/Aurora/Design/Views/Party/PartyView.xaml index ed4b37b..60838d6 100644 --- a/Aurora/Design/Views/Party/PartyView.xaml +++ b/Aurora/Design/Views/Party/PartyView.xaml @@ -18,6 +18,7 @@ HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" TabSizeOption="100" + SelectedTabIndex="{Binding SelectedTabIndex}" HeaderBackgroundColor="#232323" x:Name="TabView"> diff --git a/Aurora/Design/Views/Party/PartyViewModel.cs b/Aurora/Design/Views/Party/PartyViewModel.cs index 0b5fba2..c0958a0 100644 --- a/Aurora/Design/Views/Party/PartyViewModel.cs +++ b/Aurora/Design/Views/Party/PartyViewModel.cs @@ -34,6 +34,8 @@ namespace Aurora.Design.Views.Party private BaseMedia _selectedMedia; private ClientService _client; + private int _selectedTabIndex; + public PartyViewModel() { _members = new ObservableCollection(); @@ -59,6 +61,12 @@ namespace Aurora.Design.Views.Party #region Properties + public int SelectedTabIndex + { + get { return _selectedTabIndex; } + set { SetProperty(ref _selectedTabIndex, value); } + } + /// /// Publc property for the members list /// @@ -119,6 +127,7 @@ namespace Aurora.Design.Views.Party /// public override async Task OnActive() { + OnPropertyChanged("SelectedTabIndex"); if (this._state == PartyState.Hosting || this._state == PartyState.InParty) {