Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6958107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:05:51+00:00 2026-05-27T15:05:51+00:00

When you format a TextBox as currency and click to edit it, the $

  • 0

When you format a TextBox as currency and click to edit it, the $ and commas do not cause a problem, you can just edit and tab with no problem. When you format a field as a percentage things do not work so well.

<TextBox Text="{Binding CostMarkup, 
                         StringFormat=P}"
                Style="{StaticResource ctrlSpacingTight}" />

If the underlying value is 0.1 it correctly displays as 10%, if you go to edit it still shows as 10% the % will cause a problem plus it will change the underlying value from .1 to 10. I wrote a Converter to handle all this but I’m wondering if there isn’t a better way. In particular is there a way to handle it the way currency handles it?

There is a built in currency converter so I suspect the currency version of StringFormat uses that. While there is a ZoomPerentageConverter it doesn’t do what I would expect. Is there a way to hook in to StringFormat=P and have it invoke my Converter instead of having to go to every instance and explicitly specify it?

<TextBox Text="{Binding CostMarkup, 
                         StringFormat=P,
                         Converter={StaticResource pctConverter}}"
                Style="{StaticResource ctrlSpacingTight}" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:05:52+00:00Added an answer on May 27, 2026 at 3:05 pm

    I’ve always found that it’s easiest to display the raw data when editing, and the formatted value when not.

    Here’s an example that does that using a trigger

    <Style x:Key="ctrlSpacingTight" TargetType="{x:Type TextBox}">
        <!-- Other Style Setters -->
        <Setter Property="Text" Value="{Binding CostMarkup, StringFormat={}{0:C}}" />
        <Style.Triggers>
            <Trigger Property="IsKeyboardFocused" Value="True">
                <Setter Property="Text" Value="{Binding CostMarkup}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    

    If ctrlSpacingTight is a global style, you can create a style for your TextBox that is BasedOn your global style.

    <Style x:Key="CurrencyTextBox" TargetType="{x:Type TextBox}"
           BasedOn="{StaticResource ctrlSpacingTight}">
        <Setter Property="Text" Value="{Binding CostMarkup, StringFormat={}{0:C}}" />
        <Style.Triggers>
            <Trigger Property="IsKeyboardFocused" Value="True">
                <Setter Property="Text" Value="{Binding CostMarkup}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i attach Calendar(Global) on click event of textbox in dd-mm-yyyy format?? I
I have a TextBox and I want that the user type just numbers, not
How can I make the textbox contents to ANSI format when paste in C#?
i put the format of a textbox using expression like Format(Fields!name.Value, dd/MM/yyyy) can i
I have datetime in one simple textbox. The format of the textbox's value can
I would like to have a TextBox that displays a number in currency format
I have a textbox for entering date.Textbox should allow only dd/MM/yyyy format.How can i
Placeholder for my textbox in below format is not working for Internet Explorer. Is
How to format a textbox like 0.00 using jQuery or JavaScript? If I enter
public static void fillCheckList(string ListType,int RecordNum,CheckBox chkRequired,TextBox txtComplete,TextBox txtMemo) { string sql_Check = String.Format(@SELECT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.