0
votes

I am new in Windows Phone.

In my app I have a dialpad(0-9,*,#) and a textblock. When user presses any item on dialpad I just append it to the textblock(textblock.Text+=input).

My problem is when user presses '*', it appends to the beginning of the textblock text.

For example: If current state of textblock '1234', after pressing '*' I got '*1234' in textblock instead of '1234*'

My code is simple:

textblock.Text+=input

What is the problem?

Edit

Here's my Textblock properties where text is '123*':

<TextBlock x:Name="txtbox_input" FontSize="40" Foreground="Black" TextAlignment="Center" FlowDirection="RightToLeft" Height="60" Width="481"  HorizontalAlignment="Center"  TextWrapping="NoWrap" Text="123*" Margin="0,0,1,0" Padding="0,0,0,0"/>

But In my design view I can see '*123'

1
you can put a litthe part of your code please - MatDev8
I edited my question. - crack_head
FlowDirection="RightToLeft" it is normal? i think you want left to right no? - MatDev8
I need "RightToLeft". "LeftToRight" solve my problem. Just wondering why its happening only for '*'? Not having problem with other characters like '#'. - crack_head

1 Answers

0
votes

You should use StringBuilder to append strings from your dialpad. Here is the example, may this will help you.

string someString=string.Empty;

//When you press dialpad item
StringBuilder builtString = new StringBuilder();
builtString = builtString.Append(input);
someString = someString +builtString.ToString();
textblock.Text = someString;