private void CursorAction(object sender, RoutedEventArgs e) { Button button = sender as Button; bool toRight = Convert.ToBoolean(button.Tag.ToString()); List <char> inputList = new List <char> { }; string input = resultLabel.Content.ToString(); foreach (var c in input) { inputList.Add(c); } if (!inputList.Contains('|')) { if (!toRight) { inputList.Insert(inputList.Count() - 1, '|'); } } else { inputList.MoveCursor(toRight); } resultLabel.Content = inputList.GetLabel(); }