請誰幫我解決這個問題: 我已經定義了一個由Metro Studio創建的路徑圖標。就像這樣:爲什麼Path資源不能被多個StaticResource引用使用?
<Window.Resources>
<!--ICO Resources-->
<Path x:Key="CheckBoxOKICO" Data="M23.699997,8.8999939L26.099991,11.699997 13.099991,23.099991 5.8000031,14.599991 8.5999908,12.199997 13.5,17.899994z M1.6999969,1.6999969L1.6999969,30.300003 30.300003,30.300003 30.300003,1.6999969z M0,0L32,0 32,32 0,32z" Stretch="Uniform" Fill="#FF161616" Width="26" Height="26" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<TransformGroup.Children>
<RotateTransform Angle="0" />
<ScaleTransform ScaleX="1" ScaleY="1" />
</TransformGroup.Children>
</TransformGroup>
</Path.RenderTransform>
</Path>
<!--Button1 is OK-->
<Button x:Name="btnTaskItem1" Grid.Row="0">
<Button.Content>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Width="220">
<Viewbox Width="18" Height="18" Child="{StaticResource CheckBoxOKICO}"/>
<TextBlock x:Name="txtTaskItem1" Margin="5,0" Text="binding Task Item1"/>
</StackPanel>
</Button.Content>
</Button>
<!--Button2 is No OK-->
<Button x:Name="btnTaskItem2" Grid.Row="1">
<Button.Content>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Width="220">
<Viewbox Width="18" Height="18" Child="{StaticResource CheckBoxOKICO}"/>
<TextBlock x:Name="txtTaskItem2" Margin="5,0" Text="binding Task Item2"/>
</StackPanel>
</Button.Content>
</Button>
但是當我運行簡單的測試程序時,它給了我一個錯誤信息:
Other information: "set the property" System.Windows.Controls.Viewbox.Child "when the exception is thrown." That number is "81", "41 line position".
如果我刪除第二個按鈕中使用的第二個staticResource,它會很好用! 爲什麼我不能重用staticResource?! 感謝您的任何提示!
非常感謝你!它現在有效〜 – Wuying283