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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:34:21+00:00 2026-05-13T06:34:21+00:00

my problem is here: I have some class public class Component { … private

  • 0

my problem is here:
I have some class

public class Component
{
    ...
    private ServiceController service;

    ...
    public int ServiceStatus
    {
        get
        {
            switch(service.Status)
            {
                case ServiceControllerStatus.Stopped:
                    return 0;

                case ServiceControllerStatus.Running:
                    return 1;

                default:
                    return 2;
            }
        }
    }
    public void QueryService()
    {
        service.Refresh();
    }
}

and collection of Components, declared in another class:

public class Motivation
{
    // Downloaded data
    ...
    private ObservableCollection<Component> components;
    public ObservableCollection<Component> Components
    {
        get { return components; }
    }

    public bool CheckServices()
    {
        bool changed = false;
        foreach (Component C in components)
        {
            int prevStatus = C.ServiceStatus;
            C.QueryService();

            if (prevStatus != C.ServiceStatus)
                changed = true;
        }

        return changed;
    }

This components list displayed in WPF DataGrid. My idea: green background color for running services, red – for stopped. Works fine, but only on start. CheckServices() called by timer, and if returned value is True, i want to rerender my grid, respect to new service statuses. Here is XAML:

<Style x:Key="ServiceStateStyle" TargetType="z:DataGridRow">
        <Setter Property="Background" Value="Gray" />
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=ServiceStatus}" Value="0">
                <Setter Property="Background" Value="LightCoral" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=ServiceStatus}" Value="1">
                <Setter Property="Background" Value="LightGreen" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
    <z:DataGrid Grid.Row="0"
                Grid.ColumnSpan="4"
                AutoGenerateColumns="False"
                x:Name="DataGridComponents"
                ItemContainerStyle="{DynamicResource ServiceStateStyle}">
                <z:DataGrid.Columns>
                        <z:DataGridTextColumn IsReadOnly="True"
                            Header="Component" Width="80"
                            Binding="{Binding Path=DisplayName}"/>
                    </z:DataGrid.Columns>
                </z:DataGrid>

Should i call any method explicit to invalidate DataGrid? I have tried with InvalidateProperty, InvalidateVisual, GetBindingExpression(ItemContainerStyleProperty).UpdateTarget(), but nothing work. Can anyone help?

  • 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-13T06:34:22+00:00Added an answer on May 13, 2026 at 6:34 am

    The Component class must implement the INotifyPropertyChanged and raise the event when some of it’s property change.

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

Sidebar

Ask A Question

Stats

  • Questions 292k
  • Answers 292k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Romain Guy elaborates on a few things you can do… May 13, 2026 at 6:07 pm
  • Editorial Team
    Editorial Team added an answer You could just re-open the file? But to keep a… May 13, 2026 at 6:07 pm
  • Editorial Team
    Editorial Team added an answer Here are some basics that may help. In short, you… May 13, 2026 at 6:07 pm

Related Questions

The following is an extract from my code: public class AllIntegerIDs { public AllIntegerIDs()
EDIT: I'm now sure that the problem is related to the while (true) loop
I've got a struts2 action that responds to an AJAX request by taking some
I'm making a WebPart for SharePoint that will instantiate a Silverlight UserControl and feed
following is the code listed in MainClass.java. public class MainClass { public static void

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.