我想确保一旦我的Entry有修改(在写入时),它就会调用TextChanged
事件。但发生的情况是,该事件从未被调用。我在ASP.NET it is necessary to put AutoPostBack上看到有类似的东西要添加吗?或者是另一件事?
Xaml
<Entry
Grid.Row="0"
Grid.Column="0"
x:Name="inputUser"
FontSize="16"
Text="{Binding Input}"
Opacity="1.0001"
Focused="inputUser_Focused"
TextChanged="inputUser_TextChanged"/>
字符串
C#
void inputUser_TextChanged(object sender, TextChangedEventArgs e)
{
string oldText = e.OldTextValue;
string newText = e.NewTextValue;
if (newText.Length < oldText.Length)
{
int diff = oldText.Length - newText.Length;
for (int i = 0; i < diff; i++)
{
DeleteCommandExecute(null);
}
}
else
{
int diff = newText.Length - oldText.Length;
for (int i = 0; i < diff; i++)
{
if (newText[oldText.Length+1].ToString()=="*"|| newText[oldText.Length + 1].ToString() == "/"||newText[oldText.Length + 1].ToString() == "+" || newText[oldText.Length + 1].ToString() == "-")
{
AddOperatorExecute(newText[oldText.Length + 1].ToString());
}
else
{
AddNumberExecute(newText[oldText.Length + 1].ToString());
}
}
}
}
型
1条答案
按热度按时间cnh2zyt31#
尝试删除“Input”的文本绑定。TextChanged事件与文本绑定奇怪地不兼容。