Creating grid of hexagons

后端 未结 2 1125
执笔经年
执笔经年 2021-02-13 14:45

I have to do a \"grid\" like this:

\"Harmonic Harmonic table

I\'m trying to create a ListView

2条回答
  •  醉梦人生
    2021-02-13 15:13

    The container for your notes would be an ItemsControl or a ListBox if you need to select items. Then you give your items a template using ListBox.ItemTemplate where you include your hexagon drawing. You have a nice tutorial on Custom ListBox layout.

    At this point, your hexagons are displayed one below the other as a ListBox does by default. To get your special layout, you have to change the ListBox.ItemPanel. Here you have two possibilities:

    • either you use the Canvas panel that supports absolute positioning. In this case your items must have X and Y properties that you will use to position them.
    • or you create a custom Panel, probably based on Canvas, that is able to convert your custom coordinate system (for example note name + octave number) into X and Y. A bit more difficult but much more reusable. An example of Custom Panel on CodeProject.

提交回复
热议问题