Row Prefix - ItemsControl with UniformGrid

Posted by tenfour on Stack Overflow See other posts from Stack Overflow or by tenfour
Published on 2010-05-06T18:12:35Z Indexed on 2010/05/06 18:18 UTC
Read the original article Hit count: 257

Filed under:
|
|

I am using an ItemsControl to display a List<byte> in hex. The ItemsPanelTemplate is a UniformGrid with a fixed number of columns:

<ItemsControl 
    HorizontalAlignment="Left"
    VerticalAlignment="Top"
    ItemsSource="{Binding}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <UniformGrid Columns="16"/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding StringFormat='\{0:X2\}'}" Margin="5,5,5,0"/>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

I'd like to prefix each row with an 'Address' column, just like you'd see with the Notepad++ 'HEX-Editor' plugin.
That is, since I have 16 columns, each row should be prefixed something like this:

0000 [00 01 02 .... 0F]
0010 [10 11 12 .... 1F]
0020 [20 21 22 .... 2F]
...

Any suggestions?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about xaml