我有一个应用程序,其中有许多看起来相同且执行类似任务的图像:
<Image Grid.Column="1" Grid.Row="0" Name="image_prog1_slot0" Stretch="Uniform" Source="bullet-icon.png" StretchDirection="Both" MouseDown="image_prog1_slot0_MouseDown"/>
<Image Grid.Column="1" Grid.Row="1" Name="image_prog1_slot1" Stretch="Uniform" Source="bullet-icon.png" StretchDirection="Both" />
<Image Grid.Column="1" Grid.Row="2" Name="image_prog1_slot2" Stretch="Uniform" Source="bullet-icon.png" StretchDirection="Both" />
现在,我想将每个链接都连接到同一个事件处理程序:
private void image_MouseDown(object sender, MouseButtonEventArgs e)
{
//this_program = ???;
//this_slot = ???;
//slots[this_program][this_slot] = some value;
}
显然,图像的程序号和插槽号是其名称的一部分。当事件处理程序触发时,是否有一种方法可以提取这些信息?