我有多个XAML TextBox
,每个TextBox
都操作一个数组中对应的值。当TextBox
中的值被改变时,会使用一个C#
方法来动态检查调用该方法的TextBox
。
<TextBox x:Name="_0_0" TextChanged="_x_y_TextChanged"/>
<TextBox x:Name="_0_1" TextChanged="_x_y_TextChanged"/>
<TextBox x:Name="_0_2" TextChanged="_x_y_TextChanged"/>
// And so on.....
每个文本框都对应数组中的一个值,当 TextBox
的值改变时,使用一个 C# 方法动态检查调用该方法的 TextBox
。
private void _x_y_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox current = (TextBox)sender;
string currentname = current.Name;
string rowstring = currentname.Substring(1, 1);
string columnstring = currentname.Substring(3, 1);
int row = Convert.ToInt32(rowstring);
int column = Convert.ToInt32(columnstring);
// I've then detected the name of the textbox which has called it...
因此,这些信息可用于动态存储来自TextBox
的信息在相应的数组索引中,或者您想对其执行的任何操作...
然而,我的问题是:
我如何创建一个方法,使用我的数组中的索引位置,调用相关的TextBox
并更新其文本?