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

  • Home
  • SEARCH
  • 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 8286343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:43:16+00:00 2026-06-08T11:43:16+00:00

I have an custom UserControl I created public class MyObject : UserControl { public

  • 0

I have an custom UserControl I created

public class MyObject : UserControl
{
    public MyObject()
    {

    }
    public bool IsFinished { get; set; }
}

I added lets say 10(will be dynamic) MyObject‘s to a StackPanel and every other item i set IsFinished to true.

private void DoSomething()
{
    StackPanel panel = new StackPanel();
    for (int i = 0; i <= 10; i++)
    {
        int rem = 0;
        Math.DivRem(i, 2, out rem);
        MyObject newObj = new MyObject();
        if (rem == 0)
        {
            newObj.IsFinished = true;
        }
        panel.Children.Add(newObj);
    }
}

Now I can add the following and get the answer I am looking for (5)

int FinishedItems = 0;
foreach (object o in panel.Children)
{
    if (o.GetType() == typeof(MyObject))
    {
        if (((MyObject)o).IsFinished)
        {
            FinishedItems++;
        }
    }
}

2 Questions:

A. Is there a more eloquent way? maybe with Linq I’m still learning how to use that. From what I understand, that is what LINQ technically does.

B. Am I wrong about LINQ?

  • 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-08T11:43:18+00:00Added an answer on June 8, 2026 at 11:43 am

    So you want to count the finished items:

    int FinishedItems = panel.Children.OfType<MyObject>()
                             .Count(mo => mo.IsFinished);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do have two problems regarding custom controls: I created a custom UserControl public
I have a custom usercontrol created by myself which belongs to mine baseControls elements.
I have a custom control that inherits from UserControl , and I can't get
I have a custom base user control in silverlight. <UserControl x:Class=Problemo.MyBaseControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008
I have a custom UserControl that I created as a navigation menu that parses
Let's say I have a page with my custom UserControl (containing only asp:Literal and
I have created a usercontrol (a custom button control), how to apply skin on
I have created a custom user control with a progress overlay to get a
I have a custom UserControl with a custom DependencyProperty. To paint a better picture
I have 10 custom usercontrol's with ID's usercontrol1, usercontrol2, usercontrol3......usercontrol10. I want to add

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.