WPF通过代码访问资源的两种方式

BitmapImage source = Application.Current.Resources["OrganImage"] as BitmapImage;


BitmapImage source = this.FindResource("OrganImage") as BitmapImage;
BitmapImage source = this.TryFindResource("OrganImage") as BitmapImage;
this为FrameworkElement类型

你可能感兴趣的:(WPF)