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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:54:55+00:00 2026-06-06T12:54:55+00:00

I have the following dependency property in my MainWindow class (inherits from WPF’s Window)

  • 0

I have the following dependency property in my MainWindow class (inherits from WPF’s Window)

public ObservableCollection<ComputerListItem> ActiveComputers 
        {
            get { return (ObservableCollection<ComputerListItem>)this.GetValue(ActiveComputersProperty); }
            set { this.SetValue(ActiveComputersProperty, value); }
        }

        public static readonly DependencyProperty ActiveComputersProperty = DependencyProperty.Register(
            "ActiveComputers", typeof(ObservableCollection<ComputerListItem>), typeof(MainWindow), new PropertyMetadata(new ObservableCollection<ComputerListItem>()));

Now I’m trying to give a label the value of ActiveComputers.Count so in my XAML I have this:

<Window x:Class="ComputerManagerV3.MainWindow"        
        <!-- SNIP -->
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        >
    <Grid>
       <!--SNIP -->
        <Label Name="labelActive" Content="{Binding Source=ActiveComputers, Path=Count}" ></Label>

Even in the designer the value the label now shows is 15, strange since the list is initially filled with 13 elements. So I added some tests and no matter how much items there are in the observable collection, the label always shows the value 15 :/. There are also no binding errors shown in the output window so I’m clueless as what to do.

My questions:

  • Why is the value of the binding expression always 15?
  • How can I write a correct binding so that it always shows the number of items in the
    list
  • Is it possible to prepend some text without writing a value
    converter myself?
  • 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-06T12:54:56+00:00Added an answer on June 6, 2026 at 12:54 pm

    Your binding’s source is the literal string “ActiveComputers”, which has 15 characters in it. Thus, you’re displaying the count of characters in the string, and are not connected to the collection at all.

    Try this:

    Content="{Binding ActiveComputers.Count}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following dependency property inside a class: class FooHolder { public static
I have the following ViewModel-Property: public List<List<string>> Names .... //It's a dependency property In
I have a UserControl that I've added a Dependency Property to: public partial class
I have the following dependency property that works fine but it does not auto
I'm on a roll today... I have the following code delaring a dependency property
I have added the dependency property MyList to a wpf textbox. The dependency property
Say I have the following classes public class TestA { public string Blah {
I have the following simple TextBox subclass , which adds one dependency property (OutputIndex):
Here you have a simple WPF program: <!-- Updater.xaml --> <Window x:Class=Update.Updater xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
If I have the following class: package com.example; import org.springframework.beans.factory.annotation.Required; public class Customer {

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.