我在我的Cursor中添加了一个MainWindow.xaml文件作为资源,我如何从驻留在这个窗口中的Border元素中访问这个资源呢?
<Window.Resources>
<ResourceDictionary>
<FrameworkElement x:Key="OpenHand" Cursor="pack://application:,,,/Resources/openhand.cur"/>
</ResourceDictionary>
</Window.Resources>
<Grid x:Name="AppInterface">
// A Border is added here by code
// I want to be able to access the above resource from Border in code-behind
</Grid>发布于 2014-06-24 09:40:24
试试这个:
var elementhand = Application.Current.MainWindow.Resources["OpenHand"] as FrameworkElement;发布于 2014-06-24 09:37:23
您可以使用Application.FindResource按名称查找它们。
FrameworkElement resource = Application.Current.FindResource("OpenHand");https://stackoverflow.com/questions/24383082
复制相似问题