I am having a bug with my coding and it is really starting to get hard around
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Business_Card.Resources;
using Windows;
using Microsoft;
namespace Business_Card
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
{
}
private void TextBox_KeyPress(object sender, System.Windows.Input.KeyPressEventArgs e)
{
string[] nums = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-" };
if (!nums.Contains(e.KeyChar.ToString()))
e.Handled = true;
}
}
}
That is the full class
But here is the part with the error
private void TextBox_KeyPress(object sender, System.Windows.Input.KeyPressEventArgs e)
{
string[] nums = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-" };
if (!nums.Contains(e.KeyChar.ToString()))
e.Handled = true;
}
Specificly the line
private void TextBox_KeyPress(object sender, System.Windows.Input.KeyPressEventArgs e)
The part where it says System.Windows.Input.KeyPressEventArgs it is telling me that the namespace or name isn't found in System.Windows.Input
I have also tried doing using System.Windows.Forms; It says Forms isn't found either and I did go the the references and it wasn't found there.
Try KeyDown
event.
private void textBox_KeyDown(object sender, KeyEventArgs e)
{
string[] nums = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-" };
if (!nums.Contains(e.Key.ToString()))
e.Handled = true;
}