public List <FrameworkElement> LoadItems(ItemType it) { LoadDelegate loadDelegate = null; switch (it) { case ItemType.BinaryImage: loadDelegate = LoadImage; break; case ItemType.DrawingImage: loadDelegate = LoadDrawingImage; break; } var items = new List <FrameworkElement>(); if (loadDelegate != null) { foreach (var name in ResourcesTable.UriTable) { if (name.StartsWith(Path, StringComparison.OrdinalIgnoreCase)) { try { Uri resUri = ResourcesTable.GetUri(name); Stream stream = Application.GetResourceStream(resUri).Stream; items.Add(loadDelegate(stream)); } catch { } } } } return(items); }
public static Image LoadFromResources(string path, Assembly asm) { try { Uri resUri = ResourcesTable.GetUri(path); Stream stream = Application.GetResourceStream(resUri).Stream; var rd = (ResourceDictionary)XamlReader.Load(stream); return(new Image() { Source = (DrawingImage)rd["Layer_1"], Stretch = Stretch.Fill, UseLayoutRounding = true }); } catch { } return(new Image()); }