Font-Awesome-WPF icon indicating copy to clipboard operation
Font-Awesome-WPF copied to clipboard

ImageSourceConverter not usable as MarkupExtension ?

Open DesselBane opened this issue 8 years ago • 2 comments

Hi @charri Maybe I used it wrong but to my understanding the FontAwesome.WPF.Converters.ImageSourceConverter which inherits from MarkupExtension cannot be used as such since its ProvideValue Function returns a this refrence.

Would it be possible to adapt it a little bit so it would be usable as a MarkupExtension ?

Right now I use this as a MarkupExtension :

` public class ImageSourceFromFont : MarkupExtension { private FontAwesomeIcon _icon; private Brush _brush = new SolidColorBrush(Colors.Black);

    public FontAwesomeIcon Icon
    {
        get { return _icon; }
        set { _icon = value; }
    }

    public Brush IconBrush
    {
        get { return _brush; }
        set { _brush = value; }
    }


    public override object ProvideValue(IServiceProvider serviceProvider)
    {
        return ImageAwesome.CreateImageSource(Icon, IconBrush);
    }

`

DesselBane avatar Mar 30 '16 15:03 DesselBane

That is strange, I based the implementation of the ImageSourceConverter on this: http://stackoverflow.com/questions/7445119/improved-ivalueconverter-markupextension-or-dependencyobject

And I do see the brush change if I pass it as a parameter :/

I'll have a look over the code and try to give feedback by the end of the week.

charri avatar Apr 18 '16 10:04 charri

Ok well I guess its used in a different way then I expected. Like this you can use the Converter without declaring it as a Resource somewhere. What I though it would be used like was this:

Icon="{MarkupExtensions:ImageSourceFromFont FontIcon={StaticResource FI_Document} }"

So that you can set a Property which is an ImageSource with it directly (since there is no Binding) Maybe you could add such a MarkupExtension ?

DesselBane avatar Apr 20 '16 16:04 DesselBane