<DataTemplate x:Key="StatusColumnTemplate">
<Canvas>
<Rectangle Fill="Red" Canvas.ZIndex="1" Opacity="30" Height="{Binding Value, ElementName=Stacky}" Width="{Binding Value, ElementName=Stacky}"></Rectangle>
<StackPanel x:Name="Stacky" Orientation="Horizontal">
<Image Height="16" Margin="0,8,0,0" Opacity="{Binding Comment, Converter={StaticResource OpacityConverter}}" VerticalAlignment="Top" Width="16" Source="grade.png" Stretch="Fill"/>
<Image Height="16" Margin="5,8,0,0" Opacity="{Binding Grade, Converter={StaticResource OpacityConverter}}" VerticalAlignment="Top" Width="16" Source="/Module.Reports;Component/thumb-up.png" Stretch="Fill"/>
<Image Height="16" Margin="0,8,0,0" Opacity="{Binding Effort, Converter={StaticResource OpacityConverter}}" VerticalAlignment="Top" Width="16" Source="notepad.png" Stretch="Fill"/>
</StackPanel>
</Canvas>
</DataTemplate>
目前,矩形似乎没有绑定到stackpanel的高度和宽度。无论如何,我可以在矩形覆盖具有不透明度的数据网格单元格的情况下实现它吗?
答案 0 :(得分:1)
Height="{Binding ActualHeight, ElementName=Stacky}" Width="{Binding ActualWidth, ElementName=Stacky}"
请检查您使用的代码使用情况Value
,而应将其绑定到Stacky的ActualHeight
和ActualWidth
。