Go Back

Using Silverlight 4 StringFormat for Data Binding a TextBlock to a Slider with no decimals showing

In Silverlight 4 it is possible to use the StringFormat extention to format output from Data Binding. I was always looking for a way to remove the trailing decimals from a TextBlock that was bound to a Slider. Today I found the answer:

<TextBlock x:Name="txtWeight" Text="{Binding Value, ElementName=sldWeight, StringFormat=\{0:n0\}}"/>

This says: Use the result as a number with zero decimals.

Use StringFormat=\{0:n1\}} if you want one decimal and StringFormat=\{0:n2\}} for two decimals. You can also use StringFormat=p for Percentage, StringFormat=c for Currency…

The Designer Silverlight site has more details…

Njoy!

Facebook Twitter DZone It! Digg It! StumbleUpon Technorati Del.icio.us NewsVine Reddit Blinklist Add diigo bookmark

Comments  7

  • watches 15 okt

    http://www.960watch.com
  • rolex daytona 19 okt

    When you are looking for that perfect gift to get for the special man in your life, you can never go wrong with designer <a href="http://www.watches-mens.com" title="mens watches">mens watches</a>. The <a href="http://www.watches-mens.com/rolex-daytona" title="rolex daytona">rolex daytona</a> and the <a href="http://www.watches-mens.com/rolex-submariner" title="rolex submariner">rolex submariner</a> fall into the professional line of watches. As one of the most prestigious watch brands in the world, <a href="http://www.watches-mens.com/hublot" title="hublot watches">hublot watches</a> is specialized in splendid timepieces. <a href="http://www.watches-mens.com/panerai" title="panerai watches">panerai watches</a> aren't the most well known of men's watches but this esoteric brand is becoming highly desirable among men. <a href="http://www.watches-mens.com/breitling" title="breitling watches">breitling watches</a> have made an excellent name for themselves. If there are any watches that should be known for all the watch collectors, <a href="http://www.watches-mens.com/breitling-navitimer" title="breitling navitimer">breitling navitimer</a> should be among one of them. So far as we know, <a href="http://www.watches-mens.com/iwc" title="iwc watches">iwc watches</a> are one of the most famous brand watches in the world. Also, <a href="http://www.watches-mens.com/tag-heuer" title="tag heuer watches">tag heuer watches</a> and <a href="http://www.watches-mens.com/chopard" title="chopard watches">chopard watches</a> maybe your choice. <a href="http://www.watches-mens.com/omega-seamaster" title="omega seamaster">omega seamaster</a> watch and its tryst as an eternal timepiece began in the year 1948. 
  • rolex daytona 19 okt

    When you are looking for that perfect gift to get for the special man in your life, you can never go wrong with designer mens watches. The rolex daytona and the rolex submariner fall into the professional line of watches. As one of the most prestigious watch brands in the world, hublot watches is specialized in splendid timepieces. panerai watches aren't the most well known of men's watches but this esoteric brand is becoming highly desirable among men. breitling watches have made an excellent name for themselves. If there are any watches that should be known for all the watch collectors, breitling navitimer should be among one of them. So far as we know, iwc watches are one of the most famous brand watches in the world. Also, tag heuer watches and chopard watches maybe your choice. omega seamaster watch and its tryst as an eternal timepiece began in the year 1948.
  • rolex daytona 19 okt

    Everyone knows that swiss replica watches are the finest quality timepieces in the world. panerai watches’ great popularity is based on its high-end timepieces with high quality and top craftsmanship. One prominent feature of Hublot watches that makes the brand different from other luxury watch brands lies in the materials used in manufacturing. Also, tag heuer watches and Chopard watches are people’s choice. If there are any watches that should be known for all the watch collectors, breitling Navitimer should be among one of them. The srolex DateJust, rolex Daytona and the rolex Submariner fall into the professional line of watches. As a world known leading luxury brand, burberry watches are considered as a symbol of classic style and elegance. breguet watches have a history of more than 230 years through the arrangement of spare parts. As one of the most sought after watches in the world, patek philippe watcheshas literally stood the test of time. And Audemars Piguet watches are some of the world's best built timepieces. U Boat watches are characterized as bold, aggressive and oversized and Franck Muller watches are complex, innovative. If you are looking for a watch of high quality and superior elegance, I think B R M watches will be your choice. A Lange Sohne watches and Ferrari watches are two famous brands in the world, too.
  • rolex daytona 19 okt

    Nowadays replica watches are becoming more and more popular in the market. rolex watches are known for both their precision and elegance such as rolex air king watches, rolex submariner watches and rolex datejust watches. breguet watches are among the extremely unique and sophisticated timepieces. blancpain watches are works of excellence and decadence. bell ross watches may be well characterized by the squared military-style instrument face. With excellent craftsmanship and elegant style, Baume Mercier watches have get great value in Swiss watchmaking. bvlgari watches are noted for their fashion and precision, which make them well received in the world luxury industry. If you want to accentuate your beauty and style with good-looking accessories, chopard watches are no doubt your ideal options. dewitt watches and montblanc watches are well known brands of watches all over the world, too. oris watches are greatly sought after in the realm of luxury watches. panerai watchess are very beautiful. Their large, chunky lines are subdued by their understated styling. patek philippe watches are admired for their intricate craftsmanship and super technical advance. piaget watches are a status symbol for wealth, fortune, and prestige. If you intend to give something very special this season to people who are close to you then choose to buy rado watches. As one of the most popular timepieces in the world, tudor watches are well received by their splendid design and great durability. u boat watches is a highly elite watch brand that was founded by Italian watch maker Italo Fontana. ebel watches share the same properties with the world's most spectacular architecture in innovation, melodious and the most talented craftsmanship. ferrari watches and franck muller watches are famous for its high quality and elegant appearance. Self-producing movement is the representative of glashutte watches. gucci watches have been around since 1920 and have been leading the time peace market for many decades now. hermes watches were well received since they were first launched into the market. As one of the most prestigious watch brands in the world, hublot watches are specialized in splendid timepieces. louis vuitton watches and maurice lacroix watches maybe your best choice.
  • rolex daytona 19 okt

    As everybody known, rolex watches are some of the famous watches in the world. But they are very expensive. rolex replica watches are more and more popular now. rolex mens watches have the best selling point. The rolex Submariner and the rolex Deepsea are two of the truly exceptional sport models Rolex makes. rolex Perpetual and rolex Daytona are also the two types have special appearance and manufacture. Released in the year 1945, to mark the 40-year anniversary of the inception of Rolex, the rolex Datejust is the best selling watch of Rolex. rolex Air king is famous for its high quality and elegant appearance.
  • rolex daytona 19 okt

    As we all know, uggs Boots Shoes from Australia are made from merino lambskin in double layers.Its function in repelling moisture and coldness is even incredible.If you want to buy it,you can find ugg online through the internet.This quick guide will get you set up and on your way to finding cheap Uggs at ugg outlet prices! Because there are so many ugg website online.You can also check for prices at the more popular auction websites such as Ebay,there must be a name of ugg ebay or ugg.com.You can find many kind of ugg Boots Shoes,such as ugg nightfall bootsugg tall bootsugg butte bootugg suede boots and ugg ultra and so on.
Post a comment!
  1. Formatting options