What WPF method gives the same KeyChar like in C#?

in C#  there's a method KeyChar. when inserting a key in to a textBox it gives the value that was insert. for ex. when clicking on:5 the method gives: 5.
but Wpf doesn't have the KeyChar method.
i tried to use Key but then it gives me for ex. when i click: 5, i get: 5D5.
what method can i use to get the KeyChar like in C#?
or, maybe there's no such method and then i'll have to build one as an extension?

>>what method can i use to get the KeyChar like in C#?
There is no KeyChar property in WPF. WPF is not Windows Forms. If you handle a keydown event there is only the Key property and this returns for example Key.D1 when you press a digit.
You could easily remove the "D" or the "NumPad" part using the string.SubString method though:
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
string number;
if ((e.Key >= Key.D0 && e.Key <= Key.D9))
//digit pressed!
number = e.Key.ToString().Substring(1); // = "1" when D1 is pressed
else if (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9)
number = e.Key.ToString().Substring(6); // = "1" when NumPad1 is pressed
else
//no digit...
Hope that helps.
Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

Similar Messages

  • JSR 172: error while invoking methods with the same signature

    Hi
    I am facing a peculiar problem which is not making sense to me. This is what I have done:
    1. Written a simple web service that has two methods: sayHello and sayHellToMe. Both these methods have same signatures. They do not take in any parameter and return a string.
    2. Deployed this web service (document/literal) type on Axis 1.2
    3. Generated the stub classes from the wsdl file using Sun Wireless Toolkit's Stub Generator
    4. I have now written a MIDlet that uses this stub class to invoke both the methods one after the other.
    I enabled SOAPMonitor on Axis and saw the SOAP Request and SOAP Response messages. I observed the following:
    1. In the first method: sayHello - everything works fine (with a few tweaks in the Stub class)
    2. However, while invoking the second method sayHelloToMe, the SOAP Body tag in the SOAP Request does not contain any method name. I checked out the Stub class, the qnames and the types are all correct..
    I also realized that this behavior is seen only when I have methods with the same signature in the web service. Any idea why this might be happening? It seems like a very weird problem.
    Any help in this regard will be greatly appreciated.
    Thanks,
    Arati

    Hi, I'm closing this thread and opening the same in another as the content got pasted in reader un friendly format and i'm unable to change the format.
    Thanks,
    Ravi.

  • Accessing a private variable from a public method of the same class

    can anyone please tell me how to access a private variable, declared in a private method from a public method of the same class?
    here is the code, i'm trying to get the variable int[][][] grids.
    public static int[][] generateS(boolean[][] constraints)
      private static int[][][] sudokuGrids()
        int[][][] grids; // array of arrays!
        grids = new int[][][]
        {

    Are you sure that you want to have everything static here? You're possibly throwing away all the object-oriented goodness that java has to offer.
    Anyway, it seems to me that you can't get to that variable because it is buried within a method -- think scoping rules. I think that if you want to get at that variable your program design may be under the weather and may benefit from a significant refactoring in an OOP-manner.
    If you need more specific help, then ask away, but give us more information please about what you are trying to accomplish here and how you want to do this. Good luck.
    Pete
    Edited by: petes1234 on Nov 16, 2007 7:51 PM

  • Disappointed with IOS7, i had organized my music library as per the Genre and now im unable to hear all the songs of the same genre like in the earlier versions. The options of "all albums" and "all songs" are missing in this version of IOS. Help Please..

    Disappointed with IOS7, i had organized my music library as per the Genre and now im unable to hear all the songs of the same genre like in the earlier versions. The options of "all albums" and "all songs" are missing in this version of IOS. Help Please..

    It would be nice if you told others the steps you've tried and/or how you used to have your setup.
    Anyway have you tried tapping MORE this will then bring you to
    the selection-list of Audiobooks, Genres, Compilations & Composers.
    Selecting Genres gives you a list of all your music split into genres which was set within the Music downloaded via iTunes or uploaded from CD or which you may have set yourself.
    Then you just select the Genre you want:
    If certent songs are not correctly gategorised you may need to go into iTunes and reselect via Get-info
    >Info>Genre and change it there. That way you should end up with all songs of Jazz or other in 1 place.

  • How can I open a new window with the same website like the one I have open?

    In safari I can open a new window with the same website like the one I have open, that makes it easy continuing to navigate on a website and to go back to the original website

    Hello Andieas
    Why open a new window for fast browsing??
    Open new tabs.
    Just right click on what you want to open and click "Open in new Tab"
    It is easy and doesn't consume memory from your computer as well as easy to navigate.
    Hope you'll like it

  • Applet with 2 methods with the same name in ie

    Hi,
    I have a problem with the Java 1.5 plugin for Internet Explorer .
    When my Applet contains 2 methods with the same name but not the same return type, ie does not take the good return type.
    Here is an exemple :
    * Class TestApplet
    package test.applet;
    import java.applet.Applet;
    public class TestApplet extends Applet {
         public void init() {
              System.out.println("init()");
         public void start() {
              System.out.println("start()");
         public String test(String s) {
              System.out.println("test(String) :" + s);
              return s;
         public boolean test(int i) {
              System.out.println("test(int) :" + i);
              return true;
    }I have 2 methods test(), one returns a String and the other a boolean.
    I use the following html code :
    <html>
    <head>
    <script>
    function test() {
         alert(document.DataAccess.test("hello"));
    </script>
    </head>
    <body>
    <applet WIDTH="500" HEIGHT="200" ID="DataAccess" NAME="DataAccess" CODE="test.applet.TestApplet">
    </applet>
    <div onclick="test()">test</div>
    </body>
    </html>
    When I click on "test", the alert show "true" instead of "hello".
    The problem only occurs with a JVM 1.5. It work fine with JVM 1.4.
    Any idea ? Is it a bug ?
    Thanks.

    In your javascript method:
    function test() {
    alert(new String(document.DataAccess.test("hello")));
    MSJVM and SUN jre use different conversion from javaScript objects to Java.
    if you call from javaScript:
    document.getElementById("myApplet").myMethod(22);
    The method in MSJVM should look like this:
    public whatever myMethod(Double d);
    and SUN jre:
    public whatever myMethod(Integer i);
    The best thing to do is this:
    public whatever myMethod(Object o);
                   int col = 0;
                   if (o.getClass().getName().toLowerCase().indexOf("integer") != -1) {
                        col = ((Integer) o).intValue();
                   } else {
                        col = ((Double) o).intValue();
                   }

  • Imitating 2 keyboard buttons at the same time like ALT+F4

    hello,
    was just wonderin how to Imitatate 2 keyboard buttons at the same time like ALT+F4. i am using the Robot class to make the key board pressing and they are working fo one button. i tried two buttons like this
    robot.keyPress(KeyEvent.ALT_MASK+KeyEvent.VK_F4);but no luck. anyone know how to do this
    thanks
    martin

    martinnaughton wrote:
    sorry was just trying to do CTRL button but it does not like this bit of code.
    robot.keyPress(KeyEvent.CTRL_DOWN_MASK);
                        robot.keyPress(KeyEvent.VK_UP);gives me an exception of invalid code.It does not seem to like DOWN_MASK attributes in java.
    any way else around it
    thanks
    martinDon't confuse the modifier bitmask codes with the key codes:
    robot.keyPress(KeyEvent.VK_CONTROL);

  • CRVS2010 - open multiple rpts at the same time, like sheets in a xls file ?

    Hi all,
    is that possible to open multiple reports at the same time, like sheets in a excell file ?
    Is that possible create tabs beside the MainReport tab ? or include reports in the Group Tree ? how can I do it ?
    The application is in asp.net with VS2010 and CR2010.
    The reports used to be in excell with three sheets and now we are migrating them to crystal reports, how can I create the report with those three sheets ?
    thanks !
    Subject modified as per the sticky post at the top of this forum; [Crystal Reports for Visual Studio 2010 Beta - read before posting|Crystal Reports for Visual Studio 2010 Beta - read before posting;
    Edited by: Ludek Uher on Aug 31, 2010 7:33 AM

    I'll make the suggestion to the Program Management group.
    You may want to do a post to the [Crystal Reports Design|SAP Crystal Reports; forum and ask them how they's fake that sort of a requirement. E.g.; there may be some way to make this report look the way you want, but it will be best to ask the experts. Don't mention CRVS2010 as they don't support it and most likely you will not get an answer.
    Ludek

  • TS3297 I have an iPhone and recently bought an iPod 4 touch what l am using the same apple ID for. The iPod won't let me download songs from iTunes it is asking me security questions which I don't think I have put answers to in the first place.

    I have an iPhone and recently bought an iPod 4 touch what l am using the same apple ID for. The iPod won't let me download songs from iTunes it is asking me security questions which I don't think I have put answers to in the first place, because of this it won't let me buy any songs on iTunes

    It's probably asking you to verify the security code found on the back of your credit card.
    Regards.

  • Passing values between methods in the same class

    Hi,
    How to pass internal tables or values between methods in the same class.
    How to check if the internal method in another method is initial or not.
    How to see if the method has already been executed.
    Thanks.

    Just declare the internal table as an attribute in the class - that way every method in this class has access to it.
    Since any method has access to all class attributes you can easily check if the internal table is initial or not.
    I am not aware of any standard functionality if a method has already been executed or not, one way would be to declare a class attribute for each method and set it once the method has been executed. That way every method in that class would know which method has already been executed or not.
    Hope that helps,
    Michael

  • How do I call methods with the same name from different classes

    I have a user class which needs to make calls to methods with the same name but to ojects of a different type.
    My User class will create an object of type MyDAO or of type RemoteDAO.
    The RemoteDAO class is simply a wrapper class around a MyDAO object type to allow a MyDAO object to be accessed remotely. Note the interface MyInterface which MyDAO must implement cannot throw RemoteExceptions.
    Problem is I have ended up with 2 identical User classes which only differ in the type of object they make calls to, method names and functionality are identical.
    Is there any way I can get around this problem?
    Thanks ... J
    My classes are defined as followes
    interface MyInterface{
         //Does not and CANNOT declare to throw any exceptions
        public String sayHello();
    class MyDAO implements MyInterface{
       public String sayHello(){
              return ("Hello from DAO");
    interface RemoteDAO extends java.rmi.Remote{
         public String sayHello() throws java.rmi.RemoteException;
    class RemoteDAOImpl extends UnicastRemoteObject implements RemoteDAO{
         MyDAO dao = new MyDAO();
        public String sayHello() throws java.rmi.RemoteException{
              return dao.sayHello();
    class User{
       //MyDAO dao = new MyDAO();
       //OR
       RemoteDAO dao = new RemoteDAO();
       public void callDAO(){
              try{
              System.out.println( dao.sayHello() );
              catch( Exception e ){
    }

    >
    That's only a good idea if the semantics of sayHello
    as defined in MyInterface suggest that a
    RemoteException could occur. If not, then you're
    designing the interface to suit the way the
    implementing classes will be written, which smells.
    :-)But in practice you can't make a call which can be handled either remotely or locally without, at some point, dealing with the RemoteException.
    Therefore either RemoteException must be part of the interface or (an this is probably more satisfactory) you don't use the remote interface directly, but MyInterface is implemented by a wrapper class which deals with the exception.

  • HT1933 what if I bought the same game more than once from i tunes by mistake how can i claim a refund?

    what if I bought the same game more than once, How can I claim a refund from I tunes store?

    You can try contacting iTunes Support and see if they will refund or credit you : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • IPhoto says quit unexpectedly and will not open gives the same error over and over???

    Iphoto says it quit unexpectedly and keeps repeating the msg over and over it says to reopen and it tries then gives the same msg?

    i fixed the problem however i dont know how to delete my post?

  • My new I Phone 6 will not clearly take a photo of checks I am trying to deposit with my mobile app. I give the same check to my husband and he successfully takes a photo with his Droid. Embarrassing. Is there some setting that I have not enabled?

    I am attempting to use my banking mobile device. Each time I take a photo of a check for deposit, it says it cannot read it. I have been successful a few times, but only after numerous attempts. I give the same check to my husband and, using his Droid phone, he takes the photo and it is accepted the first time. I use a dark background, have a steady hand, and include all of the check in the frame as directed. It's so embarrassing. Is there some adjustment I need to make?
    I love the camera on this phone. It is sharp and the color is great. I don't understand why this application is so difficult. Anyone else have this problem? There is no problem with my banks' mobile banking. If there was, my husband would have a problem also. Thanks!

    Tap on the screen to get the camera to autofocus.  If the image looks clear to you, but the app isn't accepting it, it's a problem with the app.  Delete it and reinstall it.  If the issue persists, contact the app developer.

  • L2 and L3 Forwarding Method in the Same WAE

          Hi Everyone,
          Is possible to use simultaneously L2 and L3 Forwarding Method (WCCPv2) in the same WAE.
          I wanna to design a cluster with 2 WAE using the same service group in a DC and I wanna support both the L2 and L3
          Forwarding Method at the same time..
          If yes, is there any link when I can get a documentation showing some example configuration
         Thanks in Advanced,
         My Best Regards,
             Andre Lomonaco

    Hi Andrej,
             If I understand this correctly, then your best option is to use G-GRE (Generic GRE) as egress method, and use GRE redirection and MASK assignment. See an Example below.
    wccp router-list 1 172.16.10.1
    wccp tcp-promiscuous service-pair 61 62 router-list-num 1 mask-assign
    wccp version 2
    egress-method generic-gre intercept-method wccp
    For more details, please follow below CCO URL.
    http://www.cisco.com/en/US/docs/app_ntwk_services/waas/waas/v441/configuration/guide/traffic.html#wp1041742
    Ahsan

Maybe you are looking for