Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF String Format Question

Tags:

string

wpf

I have an input of a random string of twelve characters like this:

ABABABABABAB

I want them to display like this:

ABAB-ABAB-ABAB

How do I format a string in this way. I'm trying to use StringFormat, but it seems like the wrong approach.

            <TextBlock>
                <TextBlock.Text>
                    <Binding Path="Key" Mode="OneWay" StringFormat="???" />
                </TextBlock.Text>
            </TextBlock>
like image 903
Michael T Avatar asked Apr 25 '11 15:04

Michael T


1 Answers

I don't think there is a direct format string that you could use to achieve the formatting you are looking for but you can implement your own IValueConverter and use it to format your string. Here's an example (it's for WP7 but the concept it the same).

like image 83
Bala R Avatar answered Oct 11 '22 13:10

Bala R