我是WPF的新手,我試圖在一個xaml文件中創建一個新資源,並在另一個xaml文件中引用它。 即我定義WPF在另一個xaml文件中定義的自定義資源
<Window.Resources>
<ImageBrush x:Key="TileBrush" TileMode="Tile" ViewportUnits="Absolute" Viewport="0 0 32 32" ImageSource="MyImageButton.png" Opacity="0.3">
</ImageBrush>
</Window.Resources>
,並試圖通過
<Grid>
<Button Background="{StaticResource TileBrush}" Margin="5" Padding="5" FontWeight="Bold" FontSize="14">
A Tiled Button
</Button>
</Grid>
但是我得到的錯誤使用它在另一個XAML文件「的StaticResource引用‘的TileBrush’沒有被發現。」 我可以從同一個xaml文件引用資源,但不知道如何從另一個文件中執行此操作。
在此先感謝。
http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/03/creating-and-consuming-resource-dictionaries-in-wpf-and-silverlight.aspx –