我正在处理交互式地图。我使用Silverlight 4中的VisualStudio 2010 我的问题是,我不能几何分配到按钮剪辑属性:无法将几何体分配给按钮剪辑属性
代码:
bouton1.Clip = (PathGeometry)Forme.Data;
//forme is a class that inherits from Path
当我运行我的应用程序,我得到一个ArgumentException
:
值不包括在预期范围
我正在处理交互式地图。我使用Silverlight 4中的VisualStudio 2010 我的问题是,我不能几何分配到按钮剪辑属性:无法将几何体分配给按钮剪辑属性
代码:
bouton1.Clip = (PathGeometry)Forme.Data;
//forme is a class that inherits from Path
当我运行我的应用程序,我得到一个ArgumentException
:
值不包括在预期范围
你Path
称为“Forme”,其几何定义使用Path Mini-Language权限?
这种类型的几何不能被多个元素共享。
解决方法是将路径数据作为一个字符串存储在ResourceDictionary
中,您的“Forme”元素和“bouton1”均可访问,然后使用StaticResource
进行分配。喜欢的东西: -
<StackPanel>
<StackPanel.Resources>
<sys:String x:Key="MyPath">M 10,100 C 10,300 300,-200 300,100</sys:String>
</StackPanel.Resources>
<Button x:Name="btn" Content="Button" Height="150" Clip="{StaticResource MyPath}" />
<Path Data="{StaticResource MyPath}" Stroke="Black" StrokeThickness="2" />
</StackPanel>
痛苦的缺点是,VS2010设计师不理解这一点,因此不适用的路径。您需要运行该应用程序才能直观地看到结果。
我改变了Path和MouseLeftButtonDown事件的按钮,它的工作原理:)
@StefanP作者回答了他/她自己的问题。 – afuzzyllama 2012-11-13 18:24:34
有没有解决方案??? :S – Rahma 2010-07-26 11:49:21