Event bubbling in the .NET Framework refers to the process where an event raised by a child control is propagated up the control hierarchy to its parent controls, allowing them to handle the event.
It's commonly used in ASP.NET Web Forms and WPF for handling events like clicks or changes centrally at a parent level.
Example: In WPF, a Button click can bubble up to a Grid or Window if not handled.
// MainWindow.xaml
// MainWindow.xaml.cs
using System.Windows;
using System.Windows.Input;
namespace EventBubblingDemo
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("MouseDown event bubbled to StackPanel!");
}
}
}
Muhammad Imran AnsariPosted Jun 3, 2025, 7:43 AM
Event bubbling in the .NET Framework refers to the process where an event raised by a child control is propagated up the control hierarchy to its parent controls, allowing them to handle the event.
It's commonly used in ASP.NET Web Forms and WPF for handling events like clicks or changes centrally at a parent level.
Example: In WPF, a
Buttonclick can bubble up to aGridorWindowif not handled.Good Luck!