<Grid x:Name="LayoutRoot">
<TextBox x:Name="txt_remove" Height="46" Margin="234,119,225,0" TextWrapping="Wrap" VerticalAlignment="Top" GotFocus="txt_remove_GotFocus"/>
<RepeatButton x:Name="rbtn_remove" Content="Remove" Delay="500" Interval="100" Margin="283.667,183,282.333,222" RenderTransformOrigin="0.667,0.854" Click="rbtn_remove_Click" />
</Grid>
code In c#
public partial class Repeate : Window
{
Control GetTextbox;
public Repeate()
{
this.InitializeComponent();
}
private void rbtn_remove_Click(object sender, RoutedEventArgs e)
{
TextBox GetInstance = GetTextbox as TextBox;
if (GetTextbox != null)
{
string _CurrentValue = GetInstance.Text;
var _CareIndex = GetInstance.CaretIndex;
if (_CareIndex > 0)
{
string _Backspace = _CurrentValue.Remove(_CareIndex - 1, 1);
GetInstance.Text = _Backspace;
GetInstance.Focus();
GetInstance.CaretIndex = _CareIndex - 1;
}
}
}
private void txt_remove_GotFocus(object sender, RoutedEventArgs e)
{
GetTextbox = (Control)sender;
}
}
With above code i can get the result below.
If i click remove button, the textbox value clear.But If i click and hold remove button,It is not remove the textbox value repeatedly.
everything is good enough to do the work you want to do. but the focus() method call on Getinstance. is making the diffrance.
just remove .
will work.