0

I am following the tutorial here. The example contains the line

<TextBlock Text="{Binding ElementName=wnd, Path=ActualWidth, StringFormat=Window width: {0:#,#.0}}" />

binding the window width to the textblock. If I remove "#,#", I notice I get the same result except there is no comma in the number if it's greater than 999. I see what it's doing. If I change it to

<TextBlock Text="{Binding ElementName=wnd, Path=ActualWidth, StringFormat=Window width: {0:##,#.0}}" />

I get the same thing. So my question is what does # mean exactly. Looked at MSDN and searched google but almost every example does not use any # signs.

1 Answer 1

3

# is a digit placeholder numeric format specifier in .NET that is replaced with the corresponding digit if one is present. Please refer to the docs for more information.

It has nothing to do with XAML really. You might as well use it programmatically when you for example call the ToString overload of a numeric type that accepts a format string.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.