Fixed scroll animation issue
Fixed issue resetting the TabViewItem BindingContext
This commit is contained in:
Родитель
6344ed13dd
Коммит
81b8a9325d
|
@ -10,16 +10,16 @@ namespace TabView.Sample.Views
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
void OnScrollToZeroClicked(object sender, EventArgs e)
|
||||
async void OnScrollToZeroClicked(object sender, EventArgs e)
|
||||
{
|
||||
bool isAnimated = IsAnimatedScrollToCheckBox.IsChecked;
|
||||
CarouselView.ScrollTo(0, isAnimated);
|
||||
await CarouselView.ScrollToAsync(0, isAnimated);
|
||||
}
|
||||
|
||||
void OnScrollToFiveClicked(object sender, EventArgs e)
|
||||
async void OnScrollToFiveClicked(object sender, EventArgs e)
|
||||
{
|
||||
bool isAnimated = IsAnimatedScrollToCheckBox.IsChecked;
|
||||
CarouselView.ScrollTo(5, isAnimated);
|
||||
await CarouselView.ScrollToAsync(5, isAnimated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace Xamarin.Forms.TabView
|
|||
public event EventHandler<PositionChangedEventArgs> PositionChanged;
|
||||
public event EventHandler<ScrolledEventArgs> Scrolled;
|
||||
|
||||
public async void ScrollTo(int position, bool animated = true)
|
||||
public async Task ScrollToAsync(int position, bool animated = true)
|
||||
{
|
||||
if (Position == position)
|
||||
return;
|
||||
|
@ -464,7 +464,7 @@ namespace Xamarin.Forms.TabView
|
|||
UpdateViewIndex(_previousView);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AddOrUpdateCache(int key, View value)
|
||||
{
|
||||
if (_existingViews == null)
|
||||
|
@ -501,7 +501,8 @@ namespace Xamarin.Forms.TabView
|
|||
if (view == null)
|
||||
view = (View)ItemTemplate.CreateContent();
|
||||
|
||||
view.BindingContext = context;
|
||||
if (view.BindingContext == null)
|
||||
view.BindingContext = context;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -730,10 +730,12 @@ namespace Xamarin.Forms.TabView
|
|||
return;
|
||||
|
||||
SelectedIndex = newPosition;
|
||||
_contentContainer.ScrollTo(SelectedIndex);
|
||||
|
||||
Device.BeginInvokeOnMainThread(
|
||||
async () => await _tabStripContainerScroll.ScrollToAsync(_tabStripContent.Children[position], ScrollToPosition.MakeVisible, false));
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
await _contentContainer.ScrollToAsync(SelectedIndex);
|
||||
await _tabStripContainerScroll.ScrollToAsync(_tabStripContent.Children[position], ScrollToPosition.MakeVisible, false);
|
||||
});
|
||||
|
||||
if (TabItems.Count > 0)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче