HexGrid: CodeProject article
HexGrid: GitHub repository
可能的解决方案的关键组件是WPF面板,它可以排列六边形元素(标准面板使用矩形子元素)。看看我的HexGrid项目(太大,无法在此处发布)。它的中心部分是一个
HexGrid
Panel
它以蜂窝状模式排列子元素)。子元素由
HexItem
s(六边形控件)。还有
HexList
(selector items控件,它在HexGrid面板上显示HexItem容器中的项目),它提供了开箱即用的十六进制选择支持。
<hx:HexList Name="HexColors" Orientation="Vertical"
Grid.Row="1"
Padding="10"
SelectedIndex="0"
Background="{Binding Path=SelectedItem.Background, RelativeSource={RelativeSource Self}}"
RowCount="5" ColumnCount="5">
<hx:HexItem Grid.Row="0" Grid.Column="1" Background="#006699"/>
<hx:HexItem Grid.Row="0" Grid.Column="2" Background="#0033CC"/>
<hx:HexItem Grid.Row="0" Grid.Column="3" Background="#3333FF"/>
<!--...-->
<hx:HexItem Grid.Row="4" Grid.Column="1" Background="#CC9900"/>
<hx:HexItem Grid.Row="4" Grid.Column="2" Background="#FF3300"/>
<hx:HexItem Grid.Row="4" Grid.Column="3" Background="#CC0000"/>
</hx:HexList>