スタイルを使用できます:
.xaml
<Window x:Class="WpfApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<StackPanel.Resources>
<Style TargetType="Button">
<EventSetter Event="Click" Handler="Button_Click" />
</Style>
</StackPanel.Resources>
<Button x:Name="b1" Click="Button1_Click" Content="1" />
<Button x:Name="b2" Click="Button2_Click" Content="2" />
<Button Content="other" />
</StackPanel>
</Window>
xaml.cs
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine("some button");
}
private void Button1_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine("button1");
}
private void Button2_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine("button2");
}
}
app.xaml に配置すると、スタイルをアプリケーション全体に適用できます。