Images bound to images added to resx files using XAML

前端 未结 1 1103
清酒与你
清酒与你 2021-01-06 00:26

My WPF application includes a resource file MyResources.resx, containing several strings and images. Because the application will need to be localized, all my references to

1条回答
  •  礼貌的吻别
    2021-01-06 01:19

    Turn your x:Static into a Binding.Source and add a Converter which does Bitmap to ImageSource.

    Source="{Binding Source={x:Static local:Properties.MyResources.Flag},
                     Converter={StaticResource BitmapToImageSourceConverter}}"
    

    Alternatively you can make the converter a custom markup extension which takes a Bitmap and returns the ImageSource in ProvideValue.

    Source="{me:BitmapToImageSource {x:Static local:Properties.MyResources.Flag}}"
    

    0 讨论(0)
提交回复
热议问题