我有一个10x10的网格和一个横跨所有这些的画布。画布是项目控件的项目面板。这些项目绑定到BitmapImages的集合,因为我基本上需要一个图像,然后以某种方式黑色覆盖(黑色应该覆盖整个grid0。我最终还需要用户能够点击给定的单元格,然后只创建该单元格将图像显示在黑色叠加层下面。那么黑色是否应该是另一个位图或者是否有更简单的方法用网格以某种方式做到这一点?
如果有帮助,我可以发布视图模型。
的Xaml:
<Grid
ShowGridLines="{Binding ShowGridLines}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ItemsControl
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="10"
Grid.RowSpan="10"
ItemsSource="{Binding ItemsToShowInCanvas}"
Visibility="{Binding UploadButtonVisibility, Converter={StaticResource NotVisibilityConverter}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding Left}"/>
<Setter Property="Canvas.Top" Value="{Binding Top}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image
Source="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>