如何在c#中编码以访问资源中的Image my_image_name ? 因为我给了资源字典名称 mydic_name 。我可以按名称参考字典吗?
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="mydic_name">
<Image x:Name="my_image_name" x:Key="my_image_key" Source="Properties/images/device1.png"/>
</ResourceDictionary>
答案 0 :(得分:2)
假设你的ResourceDictionary
已加载,你可以这样做:
var image = (Image)Application.Current.Resources.FindName("my_image_name");