Pixata Custom Controls
For Lightswitch

Recent Posts

Popular tags (# posts in brackets)

Anonymous types (3) ASP.NET (5) C# (3) C# tricks and tips (2) Computers (6) Design patterns (3) DomainDataSource (3) Dynamic data (4) Entity framework (3) Entity model framework (5) F# (3) LightSwitch (12) Linq (6) Microsoft (2) MVP (2) MVVM (2) Project Euler (2) RIA services (5) Silverlight (2) SQL Server (4) Unit testing (4) Visual Studio (7) WCF (3) WPF (3)

Gratuitous link to StackExchange

Archives


Categories


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Actually, as I'm self-employed, I guess that means that any views I expressed here aren't my own. That's confusing!


Acknowledgments

Theme modified from one by Tom Watts
C#/F# code styling by Manoli (for posts pre-2016) and Google code prettify (for post from Jan 2016 and beyond)


My rambling thoughts on exploring the .NET framework and related technologies

The Web Image control Web Image and The Static Web Image control Static Web Image

The Web Image control Web Image

If your database contains the URI of an image located on the web, you can use this control to bind to that URI and display the image...

The Web Image control on a screen

The above image is the avatar for GusBear, who made the original suggestion for this control in a forum post. I used his avatar as a sort of homage to him for his great idea!

In the screen shot above, I used a regular textbox to edit the URI, and a Web Image control to display it. Depending on your requirements, you may want to omit the textbox and just display the image.

The usage of this control is extremely simple, you simply bind it to a screen property that contains the URI of an image, such as http://www.somedomain.com/images/sample.png. If the image doesn't exist, or the URI is invalid, the control will just be blank.

You can specify the size of the displayed image using the regular Lightswitch screen designer properties, Height and Width, so I didn't add any for the control.

This control is intended to be used where the image URI is stored as part of the screen data, most likely in a database. Whilst you can add a screen string property, set its value to the URI and bind the control to that, if you want to display an image on the web where you know the URI in advance, it's much easier to use the Static Web Image...

The Static Web Image control Static Web Image

This control works in basically the same way as above, except that it has a designer property for the image URI, and (like all static controls) ignores the bound value that is passed to it.

For some odd reason, this control has its own Height and Width properties. I'm sure there was a very good reason for this when I created the controls, but I can't remember what it was now. The only reason I can remember what I had for breakfast is that I have the same thing every day, so you can't expect me to remember the reason behind obscure design inconsistencies like this can you?

If anyone feels that they really want Height and Width properties on the Static Web Image, please let me know.