Format a Phone number using StringFormat in xaml

Hello,
I am looking to format a Phone Number in xaml. The Phone Number comes as a string to me.
<Label Content="{Binding SelectedPatientPolicy.CarrierPhoneNumber}" Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" Style="{StaticResource FieldValueStyle}"/>
Here I want to apply StringFormat as "(###) ###-####".
Please let me know how can i achieve this.
Thanks,
Abdi

You cannot apply a StringFormat on a string value in XAML. But you could use a converter class:
namespace WpfApplication24_4
public class StringToPhoneConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
string s = value as string;
if (string.IsNullOrEmpty(s) || s.Length < 10)
return value;
return string.Format("({0}) {1}-{2}", s.Substring(0,3), s.Substring(3,3), s.Substring(6,4)); //"(###) ###-####".
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
<Window x:Class="WpfApplication24_4.Window5"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication24_4"
Title="Window5" Height="300" Width="300">
<Window.Resources>
<local:StringToPhoneConverter x:Key="conv"/>
</Window.Resources>
<Grid>
<Label Content="{Binding SelectedPatientPolicy.CarrierPhoneNumber, Converter={StaticResource conv}}" Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" Style="{StaticResource FieldValueStyle}"/>
</Grid>
</Window>
The other option is to format the value of the source property directly. You cannot do this in the XAML markup anyway.
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

  • How do I change the phone number used for iMessage on iPad 4

    I want to change the phone number used on iMessage on iPad.  Any help?

    It's best to use an email address (gmail.com?) for FaceTime and iMessage on your iPad.
    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
    http://tinyurl.com/a7odey8
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
    Using FaceTime and iMessage behind a firewall
    http://support.apple.com/kb/HT4245
    iOS: About Messages
    http://support.apple.com/kb/HT3529
    Set up iMessage
    http://www.apple.com/ca/ios/messages/
    Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Setting Up Multiple iOS Devices for iMessage and Facetime
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    FaceTime and iMessage not accepting Apple ID password
    http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
    Unable to use FaceTime and iMessage with my apple ID
    https://discussions.apple.com/thread/4649373?tstart=90
    For non-Apple devices, check out the TextFree app https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8
    How to Send SMS from iPad
    http://www.iskysoft.com/apple-ipad/send-sms-from-ipad.html
     Cheers, Tom

  • How can I dial to a phone number using land line, internal PC modem and LabVIEW 8.2

    I will start to write a LabVIEW 8.2.1 program which dial to a phone number using my Dell Inspiron, Windows XP. Does any body have an idea how can I do it? or better if any body have a vi ready.
    I will appreciate your help 
    Thanks in advance
    Solved!
    Go to Solution.

    The link Somil provided is very good.
    Neddless to say that you need a modem.  And the modem's user or programmer's guide.
    Most modems have the same command structure, however, there might be some nuances depending on the manufacturer and the model, hopefully taken care by the driver.  Oh yeah..  You'll need the driver. 
    I remember reading some posts and possibly some examples somewhere in this forum.  I'm sure a search will reveal a lot of information.

  • Formating a phone number based on locale

    How can I format a phone number based on the region setting? E.g. phone numbers will be formated as (xxx) xxx-xxxx if the region is set to US. And formatted otherwise if the region is set to some other country.

    also want to know

  • TS4268 Unable to activate face time with phone number using iPad

    I've been unable to activate my Face Time with my phone number using an iPad.
    Secondly,Nigeria is not inclusive in the listed Region. What do I do?

    FaceTime and iMessage Activation
    http://support.apple.com/kb/TS4268

  • Change the contact phone number used in face time and messages

    I want to change the contact phone number used in facetime and messages, can anyone help me

    Hi Jarrod77,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at this article:
    iOS: Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/ts4268
    Best of luck,
    Mario

  • E72 - How to format the phone number on contact

    I can't figure out a easy for formatting my contact number to be like (xxx) xxx-xxxx or xxx-xxx-xxxx on e72 instead going to outlook make the changes and re-sync again. I find xxxxxxxxxx hard to read. I thought I found out how to add hypen "ctrl+(" but that basically long dash rather than short dash which you get an error if you try to send message with the phone number having the long dash. It is fine when you call. It is smart enough to strip out non-numerical value. But it is sms is not smart enough to remove it.

    ozidug wrote:
    The sad thing is that there is an international standard for phone numbers (+xxx) xxx-xxxx which everyone ought to recognise and use. It allows localisation and shortened dialling, but Nokia just want a number string. It's just lazy on thepart of the programmers; since it's a standard, they should have developed the program code once and just inserted it into every phone they produce, and that's not hard.
    A poor reflection on Nokia, I'm sad to say.
    AFAIK the international standard for telephone numbers (E.164) does not say anything about using spaces, dashes, or brackets in a telephone number.
    This may of course make it more "human readable", but claiming that what you want is a standard doesn't make it a standard, and I don't think Nokia (or any other phone manufacturer) should/could implement every single user-specific wish...

  • Ringtone format & Contact phone number transfer from another phone

    Two questions for one of the experts.
    What format are Iphone ringtones? Can you use songs previously purchased and converted to the proper format be used as a ring tone and how would someone perform this action.
    Is it possible to "bluetooth" phone number from old cell phone to the Iphone?

    What format are Iphone ringtones? Can you use songs previously purchased and converted to the proper format be used as a ring tone and how would someone perform this action.
    M4r - which is MP4 and no - not without a hack.
    Is it possible to "bluetooth" phone number from old cell phone to the Iphone?
    No - the iPhone does not support Bluetooth data transfer. All data syncing is done with a USB connection with your computer via iTunes.

  • Why does iCal insist on formatting a phone number as a hyperlink? How can I prevent this, and prevent iCal from launching FaceTime in response to entering the phone number in the event box?

    I just want to enter a phone number into an event in iCal. I do not want to launch FaceTime. How can I just put a phone number in an iCal event, without OSX 10.10 insisting on launching FaceTime in response to entering the phone number? I use a Macbook Pro.

    Megantic wrote:
    Ever since I upgraded my iPhone 4S to iOS7, it has basically become a brick.  It constantly freezes, and the home button becomes completely inoperable.  People have suggested a number of fixes for the home button problem ("calibrating", tightening screws, etc.) but none of the fixes solved the problem.  Through trial and error, I've come to realize that the problem is that the phone doesn't have enough computing power and that too much of its RAM gets used up by background processes, causing the phone to freeze.
    I have found an app that stops unnecessary background processes currently running, frees up RAM, and lets the phone function properly (Free RAM 1.3). Once I've run this app, the phone functions perfectly.
    However, this clean up only happens each time the app is launched (ie: it does not continuously free up RAM).  So, I constantly have to run it (and sometimes am not able to because the phone is frozen and the home button won't work).
    When it is running, the app  displays the background processes that are running.  Looking at the list, there are many processes for which I have no need, such as processes related to automatic checking for app updates, processes related to iCloud (which I do not use), etc.  Preventing these processes from running in the first place would go a long way in making my phone more useable (being able to return to a previous iOS would be a better option, but Apple won't allow this).
    Here is my question:  is there a way to prevent unnecessary background processes from running at all?
    Which app is this?

  • Generic funtction  return  format string Phone Number

    Hi
    I tried , tried but nothing
    I need build a Generic Function formating phone number, passing Type Telephone (Res,Cml,Cel...etc wiht 3 letters ) , Prefix can to have 3 or 4 digits and Sufix wih 4 digits
    How Can I to do It ?
    where can I to find tutorial about Regular Expression
    thank

    Asking the same question again?
    Re: Function that to Format
    Look in the documentation for regular expressions (it's not difficult to search you know!)
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_regexp.htm#ADFNS1003

  • How to change Phone Number used for activation

    Hi,
    just got myself an iPhone and when I activated it via iTunes, it took over my phone number I entered
    in my Mac account (which was my home phone number).
    This number shows now up on iTunes (when the iPhone is highlighted) as "My Number".
    I changed my number in my Mac account profile to the cellular phone number which I use, synched again (even restored the iPhone) but the old number is still shown.
    Is there any possibility to change this entry after activation of the iPhone?
    Thanks for all additional info on this (still an iPhone n00b I am)
    Cheers,
    S.

    You are right,
    it doesn't change anything on the functions itself, it's just hum, let's say "Not good looking:
    I thought that maybe there is an easy way of changing this, but it seems not...
    Anyway, if someone has an idea (maybe I have to call the local Apple Support in France on Monday for asking them though) I would be pleased if you share it with me.
    Cheers,
    S.

  • Someone else's phone number used to be assigned to an iPhone

    I am an iPhone user and I am attempting to send text messages to someone who has an Android phone.
    The messages are not being received by that person.  Apparently the receiving phone number was previously assigned to an iPhone, and my outbound message is being erroneously sent as an 'iMessage' even though the intended recipient does not have an iPhone.
    This means that someone else -- whom I do not know -- is receiving these messages.
    AT&T - the other person's carrier - has not been helpful so far.
    The problem isn't with my phone - it's working fine - it's with the interaction between AT&T and this other person's iPhone.
    How can we get this resolved?

    AT&T can't do anything other than assign a new phone number to the individual with the phone. They can't disable the iMessage activation that's tied to the number.
    Did this person have an iPhone, then get rid of it, or did they just get a new number that happens to have been tied to iMessage previously by someone with an iPhone? That seems unlikely...

  • How do I change the phone number used for I messaging?

    When I setup my iPad I used the wrong iPhone number during setup. I can I change it?

    setting>message> send and recive at

  • How do i change the phone number used for messaging?

    how do i change the telephone number for messaging?

    How do you mean? You obviously have a number on your sim. Do you mean imessage or SMS?

  • Phone number formatting using personalization

    Hi,
    Is there any way that i can format the phone number in forms using personalization so that the user should only enter the phone number in 999-999-9999(only numbers) format or else it should throw an exception.
    Thanks in advance.
    PK

    Are you talking about the D2K forms or self service pages?
    --Shiv                                                                                                                                                                                           

Maybe you are looking for

  • Unable to load OS X.3 on iMac G3

    I bought a used iMac G3, 450 mHz, 1 Gig hard drive. It came with 9.2 (which is now gone). I installed X.3 on a tower G3 earlier in the day with 9.2 on it... it went fine. Went to the iMac... put the CD in, go through all the beginning stuff, starts l

  • How to display Map for viewing in browser using Java

    I am fidning a solution for displaying political maps in browser using Java technology. Is ther anybody with a solution. Waiting for your respone. Regards Mithun

  • Error message on phone number when sending imessages

    my imessages are sending from my email account, when i went to settings>messages> recieve at> I have an error code at my phone number and only able to send as an email

  • What does NFC actually do on a laptop?

    I am looking at a T540 and I see that NFC is available as an option. I use it all the time on my smartphone, but what purpose would it serve on a laptop? Can it do file transfers like Android Beam? W540: i7-4700mq, K2100m, 8 GB DDR3L, 512 GB SSD T510

  • What dev tools are included in media kit

    Hi I am a java developer who wants to play with Solaris + java dev env for a moment I found out that JDS3 for Solaris 10 has Java Studio Creator,Java Studio Enterprise trials with it along with JES Does they all come bundled with the OS if i order a