Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9097175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:02:33+00:00 2026-06-17T00:02:33+00:00

Need help with one thing. I have DataGrid , binding it to this class:

  • 0

Need help with one thing. I have DataGrid, binding it to this class:

class Book
{
    public string Title { get; set; }
    public string Author { get; set; }
    public string Tags { get; set; }
    public string Year { get; set; }
    public string Description { get; set; }
    public string Path { get; set; }
    public int Rating { get; set; }
    public Statistics Stats { get; set; }
}

This is XAML:

<DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}" Margin="56,49,12,12" Name="booksDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" ColumnWidth="*" MinWidth="400" MinHeight="250">
        <DataGrid.Columns>
            <DataGridTextColumn x:Name="titleColumn" Binding="{Binding Path=Title}" Header="Title" Width="2*" />
            <DataGridTextColumn x:Name="authorColumn" Binding="{Binding Path=Author}" Header="Author" Width="*" />
            <DataGridTextColumn x:Name="tagsColumn" Binding="{Binding Path=Tags}" Header="Tags" Width="*" />
            <DataGridTextColumn x:Name="yearColumn" Binding="{Binding Path=Year}" Header="Year" Width="*" />
            <DataGridTextColumn x:Name="ratingColumn" Binding="{Binding Path=Rating}" Header="Rating" Width="*" />
        </DataGrid.Columns>
</DataGrid>

But I want to show Rating not like a number, but like a five images of stars. How can I convert int value to something like a panel with images?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:02:34+00:00Added an answer on June 17, 2026 at 12:02 am

    You could try something like this:

    class Book
    {
        public string Title { get; set; }
        public string Author { get; set; }
        public string Tags { get; set; }
        public string Year { get; set; }
        public string Description { get; set; }
        public string Path { get; set; }
        public int Rating { get; set; }
        public Statistics Stats { get; set; }
    
      public string displayRating 
        {
            get
            {
                if (Rating > 0)
                {
                    var temp = "";
                    for (int i = 0; i < Rating; i++)
                    {
                        temp += "*";
                    }
                    return temp;
                }
                return "No rating found";
            } 
        }
    }
    

    if your Rating property = 5, the displayRating property will be "*****".
    You could bind that displayRating property to your gridview like this:

     <DataGridTextColumn x:Name="ratingColumn" Binding="{Binding Path=displayRating}" Header="Rating" Width="*" />
    

    EDIT:

    If the maximum amount of stars you are going to need isn’t a super big number (like 30+) you could just make a .jpg for each rating.
    So you make a .jpg file with 1*, you make a .jpg with 2*..
    Then in your displayRating string do the following:

      public string displayRating 
        {
            get{ return "pathToYourJpg" + Rating + ".jpg";}
        }
    

    lets say that you have the following Jpg’s:

    c:/users/desktop/rating1.jpg
    c:/users/desktop/rating2.jpg
    c:/users/desktop/rating3.jpg
    c:/users/desktop/rating4.jpg
    

    if your rating is 4, the displayProperty rating will return "c:/users/desktop/rating4.jpg" Use this path to bind it to your datagrid.

    Something like this (not sure tho, havent actually done this myself, but it should be something like this):

    <Image Source="{Binding Path=displayRating}" Stretch="Fill" Height="100" Width="100" />
    

    this is just off the top of my head.. it’s one way how you could do it, not saying this is the best one 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If possible i'd need help with a reload thing. I mean i have this
I need help with one ajax function This is raw page setup. Page will
I really need help on this one. I am having a simple login form
I need your help with this one again. I want to send special characters
We Really need some help on this one: We've Struggled with all the Apple
Okay, I need help. I'm usually pretty good at SQL queries but this one
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
First of all, sorry for my English... I have something like this: public class
I need help with binding back after I unbind an element. Basically, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.