Skip to content

Instantly share code, notes, and snippets.

@Shosta
Created July 29, 2014 08:59
Show Gist options
  • Save Shosta/5b8673b80b4230abf32b to your computer and use it in GitHub Desktop.
Save Shosta/5b8673b80b4230abf32b to your computer and use it in GitHub Desktop.
Dismiss Keyboard from a Control in Windows Phone 8.1 - ClassExtensions
using System;
using System.Collections.Generic;
using System.Text;
using Windows.UI.Xaml.Controls;
namespace OTV.UI.Controls
{
/// <summary>
/// A Class Extensions that allows to dismiss the Keyboard from a Control.
/// Include the "OTV.UI.Controls" namespace in your class and then call the "LoseFocus" method :
/// yourControl.LoseFocus();
/// </summary>
public static class ControlExtensions
{
public static void LoseFocus(this Control control)
{
var isTabStop = control.IsTabStop;
control.IsTabStop = false;
control.IsEnabled = false;
control.IsEnabled = true;
control.IsTabStop = isTabStop;
}
}
}
@Shosta
Copy link
Author

Shosta commented Jul 29, 2014

A Class Extensions that allows to dismiss the Keyboard from a Control.

Include the "OTV.UI.Controls" namespace in your class and then call the "LoseFocus" method the following way :
yourControl.LoseFocus();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment