SfDataGrid does not show my images


Hi. I can not make my images show in datagrid. I have the files uploaded as a resource within my Gesuro project and there, in the Images folder. I follow the steps according to what you indicate in your instructions, but the images are not shown.
The rest of the data does appear correctly. I have tried with AutoGenerateColumns in both true and false.

My XAML:

                    <SfDg:SfDataGrid
                        x:Name="ThirdBasic"
                        AutoGenerateColumns="False"
                        ItemsSource="{Binding ResultsTotal}">
                        <SfDg:SfDataGrid.Columns x:TypeArguments="SfDg:Columns">
                            <SfDg:GridImageColumn HeaderText="Empresa" 
                                   MappingName="ImgSource" />
                            <SfDg:GridTextColumn HeaderText="Costo"
                                   MappingName="CostTotal" />
                        </SfDg:SfDataGrid.Columns>
                    </SfDg:SfDataGrid>

My model:

namespace Gesuro.Models
{
    public class CarQuoteResult
    {
        public CarQuoteResult(string imageStr, double costTotal)
        {
            ImgSource = ImageSource.FromResource(imageStr);
            CostTotal = costTotal;
        }
        public double CostTotal { get; set; }
        public ImageSource ImgSource { get; set; }
    }
}

My method in viewmodel (implement INotifyPropertyChanged)

        public void LoadResults()
        {
                ResultsTotal = new ObservableCollection<CarQuoteResult>
                {
                    new CarQuoteResult("Gesuro.Images.QuoteSancor.png", 985),
                    new CarQuoteResult("Gesuro.Images.QuoteMapfre.png", 628),
                };
        }

Any help please?
Thanks in advance

Sergio Cossa


Attachment: Image_of_project_b2ad3352.rar

3 Replies

SR Sivakumar R Syncfusion Team July 16, 2018 06:09 AM UTC

Hi Sergio,

We have checked your query for “SfDataGrid does not show my images”. We have prepared a sample to meet your requirement to display the images in the SfDataGrid. Please ensure the image, Build Action is set as embedded resource in the PCL project.

Refer the below image.
 

Thanks,
Sivakumar
 



SC Sergio Cossa July 16, 2018 04:21 PM UTC

Hi Sivakumar.
Thank you for your response.
Your attached image was the solution to my problem.
I forgot set the Build Action property to images.
Now, my project run correctly.
Thanks again and best regards.

Sergio


SR Sivakumar R Syncfusion Team July 16, 2018 05:27 PM UTC

Hi Sergio,

Thanks for the update. Please let us know if you have any other queries.

Regards,
Sivakumar

Loader.
Up arrow icon