Michael T
Michael T

Reputation: 1367

WPF String Format Question

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>

Upvotes: 8

Views: 390

Answers (1)

Bala R
Bala R

Reputation: 109017

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).

Upvotes: 6

Related Questions