I would like to have an EventHandle for a MouseLeftButtonDown event. When called/fired the last character of a string should be removed. My code looks like this:
public string MyString;
private void OnMouseDownDelete(object sender, MouseButtonEventArgs e)
{
int MyStringLength = MyString.Length;
MyStringLength = MyStringLength - 1;
MyString = MyString.Substring(0, MyStringLength);
}
But when I run this code a MouseLeftButtonDown event will start a loop until the string becomes empty.
Who can tell me what I am missing?
Since you are using Mango (7.1), you can use the Tap Event instead of the MouseLeftButtonDown event.
However, I suspect that the event is firing multiple times which is causing the deletion of the string.
A good practice is to use the
Handledproperty so that other control’s do not try to handle the same event:You may need to post all the code that shows how the MouseLeftButtonDown event is being added.