I've got a position readout that's very simple -- it's just a TextBlock with a Style applied to it. In that Style, I just set it like so (there are more properties than this, but I took them out for conciseness):
<Style x:Key="NumberStyle" TargetType="{x:Type TextBlock}">
<Setter Property="TextAlignment" Value="Center" />
</Style>
Now, I have one display that uses this style, and it will display a number from 0.0 to 30000.0. The problem is that since I'm centering the text, the number (if changing rapidly) jumps all over the place and it's a little disturbing. I'd like to format my string so that it won't do this.
I tried this ConverterParameter in XAML:
ConverterParameter='\{0:00000.0\}'
and while it does the padding properly, I'll get numbers like 00032.5. I then replaced the 0
with #
, but that ends up behaving just like {0:0.0}
. I looked at the MSDN docs and didn't see anything else that would help.
The only thing I can come up with is that I'd have to write a new IValueConverter to do this. In other words, in the Convert() method, I would have to take parameter
and parse it for my own special character. And then when I detect this, replace the missing numbers with spaces.
However, what I am really trying to learn here is, can this be done by simply using a different character in the format string that I don't know about?