WPF-Forge/Forge.Forms

Dynamic form support for images

hashitha opened this issue ยท 8 comments

I have now implemented most of the dynamic forms which seem to be working well.
I had a look at the code and couldn't find support for images. Is it possible to add support to load a jpg or png file?

I want to create a form similar to this one
image

This is another example.
image

Shouldn't be hard, I'll do some quick experiments and I'll let you know

I pushed master

<img src="captcha.png" />
[Image("captcha.png")]

These are the requirements for src

  • Value can be a string representing a path (I think even http works)
  • Value can be an ImageSource, which is displayed as is
  • Value can be a dynamic resource that resolves to a string or an ImageSource, if it's a string go to step 1, if it's an ImageSource go to step 2

I haven't tested it as an inline element to see how it looks, but I think we need to be able to support aligning and size properties of the image. Maybe we should allow an overriden <img width=... height=... align="left|center|right">

Inline looks good!

image

I will give this ago now and get back to you

It works well. Looks like we need to allow <img width=... height=... align="left|center|right">

I was working on that. layout is crucial for images.

I added these attributes:

<img src="..." 
    width="auto|number"
    height="auto|number" 
    align="left|center|right|stretch" 
    valign="top|center|bottom|stretch" 
    stretch="none|fill|uniform|uniformtofill" 
    direction="both|uponly|downonly" />

Defaults:

width = auto
height = auto
align = stretch
valign = center
stretch = uniform
direction = downonly

Note: if you need to make an image bigger you need to change direction

Pull latest commit for a bug fix.

This works well and it also works with an URL as an image source.