我嘗試在WPF中實現Whac a mole game。PutCheckBoxes或圖像到UniformGrid中
Molehills在 UniformGrid。取決於選項molehills是複選框或圖像。麻煩來了。
我不知道如何實現 UniformGrid同時接受複選框和圖像0。
也許你最好知道我該如何解決它。也許 UniformGrid複選框和圖像不是好主意。
我試着這樣說:
<ItemsControl Name="GameBlocksItemsControl" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=Moles}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Window}, Path=Conf.Cols}"
Rows="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Window}, Path=Conf.Rows}"
Name="MolesGrid">
</UniformGrid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
痣是對象 S的集合,這樣我就可以把有複選框或的BitmapImage。
不幸的是增加收集一些的BitmapImage年代後則不能正確顯示(而不是像那裏寫的是: System.Windows.Media.Imaging.BitmapImage)。如果我將複選框 es添加到集合中,它們顯示的很好。
我考慮寫轉換,但這種轉換器將必須知道,如果指定對象是複選框或的BitmapImage。即使它是可能的代碼,它不是很優雅的解決方案