0
我目前正在使用Silverlight 2.0 Beta 2進行測試,我的目標是定義資源元素一次,然後在我的渲染中多次重複使用它。這個簡單的例子定義了一個矩形(myRect)作爲資源,然後我嘗試重用它兩次 - 失敗並返回錯誤:在Silverlight 2.0中重新使用StaticResource
屬性{StaticResource myRect}值超出範圍。 [Line:9 Position:83]
順便說一下,這個示例在WPF中工作正常。
<UserControl x:Class="ReuseResourceTest.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="200" Height="200">
<Canvas x:Name="LayoutRoot" Background="Yellow">
<Canvas.Resources>
<RectangleGeometry x:Key="myRect" Rect="25,50,25,50" />
</Canvas.Resources>
<Path Stroke="Black" StrokeThickness="10" Data="{StaticResource myRect}" />
<Path Stroke="White" StrokeThickness="4" Data="{StaticResource myRect}" />
</Canvas>
</UserControl>
想到這裏有什麼想法。
感謝,
- 埃德