Silverlight 3元素绑定在数据表中 [英] Silverlight 3 Element binding in a datatemplate

查看:129
本文介绍了Silverlight 3元素绑定在数据表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<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>

目前,矩形似乎并未绑定到堆叠面板的高度和宽度。有没有办法,我可以通过一个矩形来覆盖具有不透明度的数据网格单元格?

Currently the rectangle does not seem to bind to the height and width of the stackpanel. Is there anyway I can achieve it where a rectangle covers a datagrid cell with an opacity?

推荐答案

Height="{Binding ActualHeight, ElementName=Stacky}" Width="{Binding ActualWidth, ElementName=Stacky}"

请检查您使用的代码使用,而应将其绑定到 ActualHeight ActualWidth 的Stacky。

Please check your code use used Value instead you should bind it to ActualHeight and ActualWidth of the Stacky.

这篇关于Silverlight 3元素绑定在数据表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆