0

So I have this XAML:

 <TextBlock.Text>
     <MultiBinding StringFormat="SomeText: &#x09;{0}&#x0a;SomeOtherText: &#x09;&#x09;{1}">
          <Binding Path="SomeBoundVar" />
          <Binding Path="AnotherBoundVar" StringFormat="{}{0:N2}" />
     </MultiBinding>
 </TextBlock.Text>

And I'd like to add a thousand separator to the 2nd binding (the StringFormat as above doesn't work). How can I do that ? Or do I have to use a converter ?

mYnDstrEAm
  • 751
  • 2
  • 8
  • 26
  • wouldn't it be easier to create a new readonly property in your viewmodel with your format? – blindmeis Nov 26 '14 at 14:21
  • 1
    Couldn't you provide the formatting in the StringFormat on the MultiBinding? e.g. {1:N2} See the docs on [composite formatting](http://msdn.microsoft.com/en-us/library/txafckwd(v=vs.110).aspx). – AndrewS Nov 26 '14 at 14:26
  • @AndrewS: Almost. It works with {1:N0} thanks! Yet I still have the problem that it's using a comma as thousands separator while I'd like to use a dot as thousands separator (couldn't find anything on that on that page though). – mYnDstrEAm Nov 26 '14 at 14:43
  • 1
    You need to get your `Thread.Current.CurrentCulture` set accordingly to have whatever separator you want. – Rafael Costa Nov 26 '14 at 14:47
  • Well it didn't work by just setting the currentculture right - I also had to do this: http://stackoverflow.com/questions/4041197/how-to-set-and-change-the-culture-in-wpf (1st answer) – mYnDstrEAm Dec 07 '14 at 12:44

1 Answers1

0

I had a same kind of issue and following is the way I fixed.

 <TextBlock>
       <TextBlock.Text>
           <MultiBinding StringFormat="{} Balance {0} : {1:##,#0.00}">
                  <Binding Path="Currency"/>
                  <Binding Path="Balance"/>
           </MultiBinding>
       </TextBlock.Text>
  </TextBlock>

Sample Result

Balance AED : 2,456.45