Events in .NET MAUI Tab View

26 May 20253 minutes to read

This section provides information about the events available in the .NET MAUI Tab View control.

TabItemTapped event

The TabItemTapped event is triggered whenever a tab is tapped.The TabItemTappedEventArgs provides the following properties:

  • TabItem : Gets the selected tab item of Tab View control.
  • Cancel : Gets or sets a value indicating whether the event should be canceled.
<tabView:SfTabView x:Name="tabView" TabItemTapped="TabView_TabItemTapped" />
tabView.SelectionChanged += TabView_TabItemTapped;
private void TabView_TabItemTapped(object sender, TabItemTappedEventArgs e)
{
   // Acces the Selected Tab Item Property
    e.TabItem.FontSize = 26;

   // Cancel the event if needed
    e.Cancel = true;
}

SelectionChanging event

The SelectionChanging event notifies before the selection changes, when the tab header is tapped, or when dynamically setting the SelectedIndex property of SfTabView. The SelectionChangingEventArgs provides the following properties:

  • Index - Gets the index value of the item that is about to be selected.

  • Cancel - Gets or sets a boolean value indicating whether the selection of the tab item should be canceled.

<tabView:SfTabView x:Name="tabView" SelectionChanging="TabView_SelectionChanging" />
tabView.SelectionChanging += TabView_SelectionChanging;
private void TabView_SelectionChanging(object sender, SelectionChangingEventArgs e)
{
    // Access the index value of the item that is being selected.
    var selectionChangingIndex =  e.Index;

    // if we set Cancel as true then the tabbed item could not selected.
    e.Cancel = true;
}

SelectionChanged event

The SelectionChanged event is used to notify when the selection changes by swiping or dynamically setting the SelectedIndex property of SfTabView. The TabSelectionChangedEventArgs provides the following properties:

  • NewValue : Gets the index of the currently selected tab item.
  • OldValue : Gets the index of the previously selected tab item.
  • Handled : Gets or sets a value indicating whether the SelectionChanged event is handled.
<tabView:SfTabView x:Name="tabView" SelectionChanged="TabView_SelectionChanged" />
tabView.SelectionChanged += TabView_SelectionChanged;
private void TabView_SelectionChanged(object sender, TabSelectionChangedEventArgs e)
{
    // Access the new and old Index
    double newValue = e.NewIndex;
    double oldValue = e.OldIndex;

    // if we set handled true other SelectionChanged event can't trigger
    e.Handled = true;
}

See also

How to convert events into commands in .NET MAUI Tab View?