【发布时间】:2010-08-24 01:24:16
【问题描述】:
我有以下问题:
我有一个列表框,其中项目位于 Canvas 上。我希望能够 xamly 定位它的元素。 ItemContainerStyle 如下所示:
<Style x:Key="ElementContainerStyle" TargetType="ListBoxItem" >
<Setter Property="Canvas.Top" Value="{Binding BoundingBox.Y}" />
<Setter Property="Canvas.Left" Value="{Binding BoundingBox.X}" />
<Setter Property="Width" Value="{Binding BoundingBox.Width}" />
<Setter Property="Height" Value="{Binding BoundingBox.Height}" />
...
</Style>
使用这种样式,SL 会因 InnerException 的消息而崩溃:
System.NotSupportedException:无法设置只读属性
为什么是只读属性?如果我将常规值放在那里(不是数据有界),它运行良好,除了 - 这不是我想要的。
我很期待 SL4 的新功能(比如绑定到 Width 和 Height 属性的能力),但似乎这样的技巧仍然无法完成?
它在 WPF 中运行良好..
任何人都可以对此有所了解吗?
【问题讨论】:
标签: silverlight-4.0