Created
July 29, 2014 08:59
-
-
Save Shosta/5b8673b80b4230abf32b to your computer and use it in GitHub Desktop.
Dismiss Keyboard from a Control in Windows Phone 8.1 - ClassExtensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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();