我正在處理交互式地圖。我使用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