I'm trying to display an image for a row when that row has a file (in this case a PDF) attached to it. I have a True/False column called 'FileExists' which indicates if the row has a document associated with it.
So based on this this those rows that have a True value in the FileExists column should display an image. I want the ability then to allow the user to click the image to open the assigned PDF file.
I have had a few attempts at this now based on other posts but can quite get it to work properly.
Any help would be most appreciated.
Troy
Hello Troy,
Thank you for your post. I have been looking into your requirement and I created a sample project for you with the functionality you want. Basically I created a Style for the CellValuePresenter of the Boolean Field and change its ControlTemplate to has an Image and added a Converter to set different Images depending on the value of the Field. Also I bind the IsEnabled Property to the value, too, so that only the images of the records that has File can be clicked. Please let me now if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Thanks Stefan! That worked like a charm, exactly what I was trying to achieve. Much appreciated.
Hello,
It seems like that your DataContext is set to CellValuePresenter, so you have to set the Binding's Path to Record.Cells["MessageType"].Value. If this doesn't help you, could you please send me an isolated sample project, where your issue is reproduced, so I can investigate it further for you.
Hi Stefan,
I've generated a sample project, in it is a SQL script to run to create the dependent table and inserts 2 rows of test data, also you will need to alter the connection string which I've hardcoded for the sample purpose.
You will single a single converter as well which also displays images which is working, as you'll see when you run the app. That one is fine, it the multi converter column I'm having the issue with, the field is called 'Direction'.
Hopefully, you can see what I'm missing.
Thansk,
I can suggest you change the Binding like this:
<Binding RelativeSource="{RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}" Path="Record.Cells[MessageType].Value"/>
Hope this helps you.
thanks Stefan that binding change worked. I also had to make a change in my MultiValueConverter class to use the ImageSourceConverter class rather than just returning a string as the image source.
new ImageSourceConverter().ConvertFromString(imagePath + "EmailReceived.png");
thanks so much.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.