WPF - Byte Array to Hex View (similar to Notepad++ HEX-Editor plugin)
- by tenfour
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?