thumbmunkeys
thumbmunkeys

Reputation: 20764

Text Control and colored background

In my application I have a control that displays hex data:

alt text

I want to color code the different bytes. Currently I use a TextBlock for displaying the hex data, I dont think it is possible to color the individual bytes differently with that.

So my question is: Which control do I have to use to color code the text?

Are there any other means to achieve such a color coding?

Upvotes: 1

Views: 153

Answers (2)

biju
biju

Reputation: 18000

Try this

    <Label>
        <StackPanel Orientation="Horizontal">
            <TextBlock Background="Red" Text="S"/>
            <TextBlock Background="Blue" Text="O"/>
        </StackPanel>
    </Label>

Upvotes: 0

Tim Lloyd
Tim Lloyd

Reputation: 38434

Consider using a TextBlock, but break the elements up using Run blocks, e.g.

    <TextBlock>
        <Run Background="Red">A</Run>
        <Run Background="Blue">B</Run>
    </TextBlock>

Upvotes: 3

Related Questions