I have an app that runs on a touchscreen and I am trying to capture the GotTouchCaptureEvent so that I can display the onscreen keyboard when the textbox is touched. It worked fine for a TextBox, but I am converting to RadMaskedTextInput controls to take advantage of the input masking and input validation. The event is fired from the TextBoxes (it works as desired if I change RadTouchTextBox to derive from TextBox), but not from the RadMaskedTextInput controls. The GotFocus and the LostKeyboardFocusEvent both work fine.
Here is the code:
ViewModel:
public class RadTouchTextBox : RadMaskedTextInput
{
/// <summary>
/// TextBox class with event handlers
/// </summary>
public RadTouchTextBox()
{
this.GotFocus += TextBox_GotFocus;
this.GotTouchCapture += TextBox_GotTouchCapture;
this.LostKeyboardFocus += TextBox_LostKeyboardFocusEvent;
}
private static void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
(sender as TextBox)?.SelectAll();
}
private static void TextBox_GotTouchCapture(object sender, RoutedEventArgs e)
{
try
{
Process.Start(@"c:\Program Files\Common Files\microsoft shared\ink\tabtip.exe");
}
catch
{
// if the tabtip display fails for any reason, do nothing.
}
}
private static void TextBox_LostKeyboardFocusEvent(object sender, RoutedEventArgs e)
{
Process[] processlist = Process.GetProcesses();
foreach (Process process in processlist)
{
if (process.ProcessName == "TabTip")
{
try
{
process.Kill();
}
catch
{
// if killing the process fails, ignore
}
break;
}
}
}
public string ServerPath
{
get { return GetProperty<string>(); }
set { SetProperty(value); }
}
xaml:
<DockPanel>
.
.
.
<RadTouchTextBox Width="300" Margin="5" FontSize="24"
Value="{Binding ServerPath, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, ValidatesOnExceptions=True}"
</DockPanel>
Any help is appreciated.
George