Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

ImageSourceConverter not usable as MarkupExtension ? #27

Open
DesselBane opened this issue Mar 30, 2016 · 2 comments
Open

ImageSourceConverter not usable as MarkupExtension ? #27

DesselBane opened this issue Mar 30, 2016 · 2 comments
Assignees
Labels

Comments

@DesselBane
Copy link

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);
    }

`

@charri
Copy link
Owner

charri commented Apr 18, 2016

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 charri added the bug label Apr 18, 2016
@charri charri self-assigned this Apr 18, 2016
@DesselBane
Copy link
Author

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 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants