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 6698731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:36:45+00:00 2026-05-26T06:36:45+00:00

My XML data is: <Num>12.6</Num> I bind this to a XAML TextBlock and want

  • 0

My XML data is:

<Num>12.6</Num>

I bind this to a XAML TextBlock and want to display the value as a rounded number without decimal point. So this value should be displayed as 13. Similarly, 12.2 should be displayed as 12, etc.

I need code in the StringFormat below (at the …) to do what I want:

<TextBlock Text= "{Binding Num, StringFormat=...}" />

Thanks.

  • 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-26T06:36:46+00:00Added an answer on May 26, 2026 at 6:36 am

    Try using a converter:

    public class StringToDoubleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return double.Parse(value as string);
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    Then in xaml, declare the converter:

    <UserControl.Resources>
        <local:StringToDoubleConverter x:Key="StringToDoubleConverter"/>
    </UserControl.Resources>
    

    And finally use it in the binding, together with the StringFormat:

    <TextBlock Text= "{Binding Num, StringFormat=n0, Converter={StaticResource StringToDoubleConverter}}" />
    

    The zero in n0 indicates no decimal places (Standard Numeric Format Strings)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my xml data has nodes in this format . I want to suppress the
We want to take XML data and convert it to an NSDictionary object, but
How can I parse XML data using PHP? I want to get the contents
I have a very simple XML file: <?xml version=1.0 encoding=ISO-8859-1?> <Data><Day Num=4197> <Date>270611</Date> <Energy>47</Energy>
Have a xml data like <Items><Item><name>test1</name></Item><Item><name>test2</name></Item></Items> Looks like jaxb cannot unmashall this when defining
I have data in XML format. Example is shown as follow. I want to
I have the following Code to display Data from the Database in XML Document
I want to select nodes based on some variables. The XML code: <data> <prot
My data.xml <?xml version=1.0 encoding=ISO-8859-1?> <catalog> <cd country=UK> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <price>10.0</price>
I'm trying to parse data from Archive.org's search functionality. The data looks like this:

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.