This could be what you wanted to have:
MainWindow.xaml:
<Window x:Class="WpfApplication10.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">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="Width" Value="75"></Setter>
<Setter Property="Height" Value="25"></Setter>
<Setter Property="Margin" Value="5"></Setter>
</Style>
</Window.Resources>
<Grid>
<StackPanel x:Name="stackPanelButtons" Button.Click="CommonClickHandler">
<Button Content="01"/>
<Button Content="02"/>
<Button Content="03"/>
<Button Content="04"/>
<Button Content="05"/>
<TextBlock x:Name="textBlock"></TextBlock>
</StackPanel>
</Grid>
</Window>
MainWindow.xaml.cs:
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication10
{
public partial class MainWindow : Window
{
List<string> values;
public MainWindow()
{
values = new List<string>();
InitializeComponent();
}
private void CommonClickHandler(object sender, RoutedEventArgs e)
{
string value = ((Button)e.Source).Content.ToString();
if(values.Contains(value))
{
MessageBox.Show(this, string.Format("'{0}' already exists!", value), "Info", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
values.Add(value);
}
textBlock.Text = string.Join("-", values);
e.Handled = true;
}
}
}