Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Update TabView.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
felipebaltazar committed Nov 16, 2024
1 parent 3694fa9 commit b8bbe29
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions Maui.CommunityToolkit.TabView.Compat/TabView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,38 @@ void DisableLoop()

public void Dispose()
{
if (contentContainer != null)
try
{
contentContainer.PropertyChanged -= OnContentContainerPropertyChanged;
contentContainer.Scrolled -= OnContentContainerScrolled;

if (contentContainer != null)
{
contentContainer.PropertyChanged -= OnContentContainerPropertyChanged;
contentContainer.Scrolled -= OnContentContainerScrolled;
}
}
catch (Exception _) { }

try
{
if (tabItemsSource is INotifyCollectionChanged notifyTabItemsSource)
notifyTabItemsSource.CollectionChanged -= OnTabItemsSourceCollectionChanged;
}
catch (Exception _) { }

if (tabItemsSource is INotifyCollectionChanged notifyTabItemsSource)
notifyTabItemsSource.CollectionChanged -= OnTabItemsSourceCollectionChanged;
try
{
if (TabItems != null)
TabItems.CollectionChanged -= OnTabItemsCollectionChanged;

if (TabItems != null)
TabItems.CollectionChanged -= OnTabItemsCollectionChanged;
}
catch (Exception _) { }

var lazyView = (contentContainer?.CurrentItem as TabViewItem)?.Content as BaseLazyView ?? TabItems?[SelectedIndex].Content as BaseLazyView;
lazyView?.Dispose();
try
{
var lazyView = (contentContainer?.CurrentItem as TabViewItem)?.Content as BaseLazyView ?? TabItems?[SelectedIndex].Content as BaseLazyView;
lazyView?.Dispose();
}
catch (Exception _) { }
}

public ObservableCollection<TabViewItem> TabItems { get; set; }
Expand Down

0 comments on commit b8bbe29

Please sign in to comment.