What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 11472 |  Welcome, Guest!   Register  Login
  Home > Community Home >

Tip: Binding an Image element's Source property to a Uri in WinRT XAML

  Posted on: 3/27/2012 3:00:23 PM | Views: 41

Recommend an Articles | Recommended Articles | Search Resources | Community Home |




Over the years, I've conditioned myself to use the Uri classwhen surfacing web URLs in my application. Early versions ofSilverlight couldn't bind an image source directly to an instanceof a Uri because they lacked an appropriate type converter; theusual workaround was to change the property to a string type.
Subsequent versions Silverlight added that capability and theconverter. For example. Given an instance of the following modelclass as the data context:
public class Tweet
{
public string Message { get; set; }
public Uri Image { get; set; }
}In Silverlight, you can bind in XAML like this:

<Image Source="{Binding Image}" />
In the current version of Windows 8/WinRT XAML, you can't bindimage sources directly to Uris, but there's a nice way to do it byusing property element syntax and and a BitmapImage class. It'smore verbose, but may be just the ticket if ... Go to the complete details ...

Found interesting? Add this to:


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/23/2013 9:44:01 PM