There's a few ways.
If the button click handler is in the same class as the buttons could you search for it?
for (var i = 0; i < count; i++)
for (var j = 0; j < count; j++)
if (bt[i, j] == sender)
{
// found it
}
Or you can set the Tag of the button.
bt[i, j].Click += Button_Click;
bt[i, j].Tag = Tuple.Create(i, j);
Another is to create a closure for the click handler.
private Action<object, RoutedEventArgs> Button_Click(int i, int j)
{
return (object sender, RoutedEventArgs e) =>
{
(sender as Button) ???
};
}
bt[i, j].Click += Button_Click(i, j);