Yes, .ico files can be added as DynamicResource(and, of course, because it is a resource it must have x:Key).
However, they will not automatically resize. Each size is extracted from .ico, like this, in which I make Imagefor each of the icon frames set to the exact frame size, and then add that Imageto StackPanel, calledimageStack
var iconUri = new URI( "pack://application:,,,/MyIcon.ico", UriKind.RelativeOrAbsolute );
var iconDecoder = new IconBitmapDecoder( iconUri,
BitmapCreationOptions.None, BitmapCacheOption.Default );
foreach ( var frame in iconDecoder.Frames ) {
var img = new Image(){
Height = frame.PixelHeight,
Width = frame.PixelWidth,
Source = frame }
imageStack.Children.Add( img );
}
.ico , , , Image / Image, Button , .
, , , :
BitmapFrames ResourceDictionary , 'MyIcon16', 'MyIcon32' ..MarkupExtension IValueConverter, , , .DynamicResource, .- . 32x32-
Window ResourceDictionary 'MyIcon' 64x64 , Grid Window. , {DynamicResource MyIcon} Grid, 64x64 , 32x32 .