Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Image converter , 'Settings image is not displayed when using this converter for the image control

$
0
0

Hi,

I am using a image converter , which picks the settings.png icon from resource file .

All the other images are displaying properly whereas the settings icon  is not displayed correctly a  darkblackground is displayed on the image instead,I am not setting any background for the button.

Button is there , inside button i created image and binded source to ''.

Converter :

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var ms = new MemoryStream();
            ((Bitmap)value).Save(ms, ImageFormat.Bmp);
            var image = new BitmapImage();
            image.BeginInit();
            ms.Seek(0, SeekOrigin.Begin);
            image.StreamSource = ms;
            image.EndInit();
            return image;
        }

Xaml:

<Button x:Name="BtnSettings" Click="BtnSettings_OnClick">
                        <Image Source="{Binding Source={x:Static prop:Resources.setting_icon},Converter={StaticResource BitmapConverter}}" Width="20" Height="20" Margin="2,0,0,0" Stretch="None"/>
                    </Button>


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>