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 6854317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:37:06+00:00 2026-05-27T01:37:06+00:00

I am using a gridview inside a listview.My grid view has two colums ID

  • 0

I am using a gridview inside a listview.My grid view has two colums ID and Result.I am loading the gridview from a List.So result column has two types of values positive and negative.I want to display text color green for positive and red for negative and also attach an icon alongside the textblock.

Is it possible in xaml ? Or am i trying to implement which is not possible ?

How to bind the color based on the values coming from the list into the grid ?

 <ListView Height="166" HorizontalAlignment="Left" Margin="23,0,0,0" Name="lvStatus" VerticalAlignment="Top" Width="264">
        <ListView.View>
            <GridView>

                <GridViewColumn Header="Result">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock  Text="{Binding Path=Result}"/>
                                    <Image  ></Image>
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>
  • 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-05-27T01:37:06+00:00Added an answer on May 27, 2026 at 1:37 am

    Create a Converter that returns Green if the specified value is above 0, and Red if it is below 0, and use it to determine the Foreground color of your Text

    public class NumberToColorBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is double)
            {
                return (((double)value) > 0 ? Brushes.Green : Brushes.Red);
            }
    
            throw new Exception("Invalid Value");
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    You can then use your converter like this:

    <Window.Resources>
        <local:NumberToColorBrushConverter x:Key="NumberToColorBrushConverter" />
    </Window.Resources>
    
    <TextBlock Text="{Binding Result}" Foreground={Binding Result, 
        Converter={StaticResource NumberToColorBrushConverter}}" />
    

    Edit

    If you have a value in your data which determines Positive or Negative, then you don’t even need to use a Converter. Here’s an example that uses a DataTrigger

    <Window.Resources>
        <Style x:Key="ResultTextBlockStyle" TargetType="{x:Type TextBlock}">
            <Style.Triggers>
                <Setter Property="Foreground" Value="Green" />
                <DataTrigger Binding="{Binding PositiveOrNegative}" Value="Negative">
                    <Setter Property="Foreground" Value="Red" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    
    <TextBlock Text="{Binding Result}" Style="{StaticResource ResultTextBlockStyle}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using an gridview inside the update panel.now in that grid i have 3
I have a ListView which is using a GridView to display a DataTable and
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
How to show in the WPF Listview using the GridView an empty text (like
I have a gridview inside UpdatePanel. One of the column in gridview is link
I'm displaying four data fields in a single column of a gridview using template
I am using a text box inside a GridView as ItemTemplate field. I have
I am creating a calendar using GridView (6 row * 8 column). Each of
I have a GridView inside UpdatePanel and also a HoverMenuExtender declared. GridView also has
I have a GridView that is inside of an UpdatePanel. I am using the

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.