i have a text block where all text display on button click by user.
XAML
<TextBlock x:Name="TextDisplay" TextAlignment="Center"
Style="{StaticResource PhoneTextTitle1Style}" />
<Button Style="{StaticResource MyButtonStyle}" Content="1" Click="Number_Click" />
<Button Style="{StaticResource MyButtonStyle}" Content="2" Click="Number_Click" />
<Button Style="{StaticResource MyButtonStyle}" Content="3" Click="Number_Click" />
<Button Style="{StaticResource MyButtonStyle}" Content="4" Click="Number_Click" />
<Button Style="{StaticResource MyButtonStyle}" Content="5" Click="Number_Click" />
<Button Style="{StaticResource MyButtonStyle}" Content="6" Click="Number_Click" />
<Button Style="{StaticResource MyButtonStyle}" Content="7" Click="Number_Click" />
<Button Style="{StaticResource MyButtonStyle}" Content="8" Click="Number_Click" />
<Button Style="{StaticResource MyButtonStyle}" Content="9" Click="Number_Click" />
<Button Style="{StaticResource MyButtonStyle}" Content="0" Click="Number_Click" />
And i want when user click on button content of button show in text block, but in this limited format ("###.##") only.
C#
private void Number_Click(object sender, RoutedEventArgs e)
{
Button b = (Button)sender;
TextDisplay.Text += b.Content.ToString("###.##");
}
but show error on ToString when i erase "###.##" code works, but button can be click infinitely.
Platform : windows phone silverlight app /c# help if any body know to show text in textblock in "###.##" this limited format only.
you can use
like
The "0" custom format specifier serves as a zero-placeholder symbol. If the value that is being formatted has a digit in the position where the zero appears in the format string, that digit is copied to the result string; otherwise, a zero appears in the result string. The position of the leftmost zero before the decimal point and the rightmost zero after the decimal point determines the range of digits that are always present in the result string.