Silverlight 3 Element binding in a datatemplate

前提是你 提交于 2019-12-12 02:07:42

问题


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


回答1:


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

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



来源:https://stackoverflow.com/questions/3957389/silverlight-3-element-binding-in-a-datatemplate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!