Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
Show an image exposed in an object property
posted

Public Class Car
    Implements INotifyPropertyChanged

    Private m_make As String
    Private m_model As String
    Private m_baseprice As Double
    Private m_mileage As Integer
    Private m_image_path As String

    Public Property ...

End Class

I've bound a Car Class' collection to a xamDataCarousel with AutoGenerateFields set to True.

Know I want to add an image to the Car Class to be shown in the carousel. I've tried, without success, to add a public property returning a System.Drawing.BitmapImage and System.Windows.Control.Image from the image path (m_image_path). Is there any concrete type for an image to be bound?

  • 69686
    Suggested Answer
    posted

    There are couple of ways to achieve this:

    1. If you choose to have a property with path, you should make it Uri type. In the CellValuePresenter, you should put an image and bind its source property to the path property.

    2. You can return System.Windows.Control.Image, but you would have to use a converter for the Content of the CellValuePresenter.

    You should really consider the first approach. You can see sample for this in the XamFeatureBrowser under XamDataGrid - Themes and Custom Styles - Embedded Image Fields.