How to Disable Windows Phone 8 Keyboard buttons? - windows-phone-7

I'm working on windows phone 8 textBox where i just change the inputscope of the textbox to number/digits. Problem is there is no use of dot(decimal point) button in the textbox so i want to disable the dot button or when user click on that button it does not reflect in the textbox i need to input only numbers. So Please help me in this Problem as i'm beginner. Thanks a lot.

You can just attach to the TextBox.KeyDown event and set it to Handled = true when a . is inputed, like this:
private void MyTextBox_OnKeyDown(object sender, KeyEventArgs e)
{
if (e.PlatformKeyCode == 190)
{
e.Handled = true;
}
}
The code for . is 190

Related

How to enable PhoneApplicationPage_BackKeyPress event when set textbox.Focus() on textbox_LostFocus event in windows phone 8

How to enable
PhoneApplicationPage_BackKeyPress
event when set textbox.Focus() on textbox_LostFocus event in windows phone 8.
I want to show keyboard when i add some item into listbox from textbox. Listbox gets update but my keyboard always gets hide on button click.
I want to make it open all the time till i press back key.
Thanks,
Nishant
you can get BackKeyPress Event by :
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
base.OnBackKeyPress(e);
}
You can write textbox.Focus() at the end of button click when all work is done
try this :
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
ListboxName.Items.Add(TextBoxName.Text);
TextBoxName.Text = "";
TextBoxName.Focus();
}
I have implemented. Its working...

Windows Phone 7 Back Key Press event change?

I want to do some work if user presses back key on the phone with navigating back How to do it?
With following code it cancel navigation to back page & do some stuff but i want to do stuff while going back please help...
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
// do some stuff...
e.Cancel = true;
}

pop up with editable text in windows phone 7

I want to give the privilage for the user to rename a file. For that When the user clicks on menu item 'rename'a pop up dialogue with and editable text box should show up with 'ok' and 'cancel' buttons? How can i implement it? Pls share the code if there are any.
Br,
Jinu
You can use the InputPrompt from the Coding4fun Tookit
The documentation is available on Codeplex: http://coding4fun.codeplex.com/wikipage?title=InputPrompt&referringTitle=Documentation
Calling it is straightforward:
var input = new InputPrompt();
input.Completed += InputCompleted;
input.Title = "Rename file";
input.Message = "Enter a new name for the file:";
input.Show();
Then you just have to retrieve the value in the callback:
private void InputCompleted(object sender, PopUpEventArgs<object, PopUpResult> e)
{
MessageBox.Show(e.Result);
}

Overriding <Enter> key behaviour in Windows Phone 7.1

I'm developing an app for Windows Phone 7.1. I was wondering if it is possible to override the behaviour of the enter button on the virtual keyboard. Basically, I want the user to be able to submit the form if he/she presses the enter button when filling the last field of the form. Please let me know if it is possible or if the convention is not to do so.
Thanks.
There is event OnKeyDown for this purpose
textblock.OnKeyDown += (s, e) =>
{
if (e.Key = Key.Enter)
{
//do your stuff here
}
};

How can I tell when the "search" button is clicked when I set InputScope to search?

For Windows Phone. How can I tell when the "search" button is clicked when I set InputScope to search on a TextBox? Is there an event?
When the InputScope is set to "Search", the "search" button is just a restyled "enter" button. So, assuming:
<TextBox InputScope="Search" KeyDown="SearchBox_KeyDown" />
the "search " button being pressed (on the SIP) can be detected with:
private void SearchBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
// Do search...
}
}
In addition to what Matt has (correctly) answered, if you handle e.PlatformKeyCode == 0x0A (as shown below) you can also respond to the Enter key being pressed on the host keyboard when running in the emulator without the SIP.
if ((Key.Enter == e.Key) || (e.PlatformKeyCode == 0x0A))
{
// Do search...
}
Do you mean the hardware search button? It's not exposed.
Similar question
For Windows Phone 8.1 Apps (not Silverlight) you may use VirtualKey
if (e.Key == Windows.System.VirtualKey.Enter)
{
//Do Something.
}

Resources