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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:40:15+00:00 2026-06-02T12:40:15+00:00

The setup So I have a class, ComputerItem , designed to store everything I

  • 0

The setup

So I have a class, ComputerItem, designed to store everything I need to know about a specific computer; these items are stored in an ObservableCollection<ComputerItem>. I then have a custom control ComputerControl, which has (among other things) a few text boxes bound to members of ComputerItem, the bindings made available like so:

<TextBlock Name="tb_computerName"TextWrapping="Wrap" Text="{Binding ElementName=ComputerControl1, Path=computerName}"/>

and in the code behind

public static DependencyProperty computerNameProperty = DependencyProperty.Register("computerName", typeof(string), typeof(ComputerControl), null);

I then create a MultiselectList of ComputerControl objects:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <toolkit:MultiselectList x:Name="lb_computers" IsSelectionEnabledChanged="lb_computers_IsSelectionEnabledChanged"> <!--SelectionChanged="lb_computers_SelectionChanged" >-->
        <toolkit:MultiselectList.ItemTemplate>
            <DataTemplate>
               <StackPanel x:Name="sp">
                    <local:ComputerControl computerName="{Binding Name}" MACAddress="{Binding DisplayMAC}" playClicked="playClicked_Handler" editClicked="editClicked_Handler"/>
                </StackPanel>
            </DataTemplate>
        </toolkit:MultiselectList.ItemTemplate>
    </toolkit:MultiselectList>
</Grid>

and you can see the data bindings in the ComputerControl definition. In the code behind I bind the ObservableCollection to the MultiselectList:

this.lb_computers.ItemsSource = ComputerListMaintainer.GetList();

and all of this (as well as a few things I’m sure I’ve forgotten to include here) works beautifully to fill the MultiselectList with ComputerControls representing the ComputerItems in the ObservableCollection.

The problem

My issue is that when the underlying ComputerItem changes, the TextBlocks in the corresponding ComputerControl don’t update. I’ve implemented INotifyPropertyChanged in the ComputerItem class:

public class ComputerItem : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    private string name;

    protected virtual void OnPropertyChanged(string name)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(name));
    }
    public string Name
    {
        get { return name; }
        set { OnPropertyChanged("Name"); name = value; }
    }
}

but that didn’t solve the problem. I suspect it’s something to do with ComputerControl but I have no idea where to start looking; the closest question I’ve found suggested INotifyPropertyChanged should have been the solution but they weren’t using a custom control in that case, just a custom class, if I remember correctly.

What am I missing?

  • 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-02T12:40:17+00:00Added an answer on June 2, 2026 at 12:40 pm

    Well your setter is incorrect for starters; also do look into MvvmLight, as it provides a great API for this kind of plumbing work.

    public string Name
    {
        get { return name; }
        set 
        { 
            if(value != name)
            {
                name = value;
                OnPropertyChanged("Name"); 
            }
        }
    }
    

    Update:

    You shouldn’t be setting lb_computers.ItemsSource in your code behind, because that’s one time operation and not a binding. It is better to bind to an ObservableCollection of observable objects (aka INotifyPropertyChanged).

    Also I’m not sure if you’re properly declaring your dependency property, so below you can find a proper setup on how to define a ‘bindable’ property.

    And also with XAML, the architecture of your code matters, to have a sane experience. I highly recommend that you utilize the Mvvm pattern. I find MvvmLight and MEFedMVVM to be great aids in my development. This require a bit of work at the beginning, but it’ll be far easier to debug future issues and maintain your code.

    If these tips don’t help, then I’d have to see your full code.

    Declaring a Bindable Property

    #region ReportName
    
        public string ReportName
        {
            get { return (string)GetValue(ReportNameProperty); }
            set { SetValue(ReportNameProperty, value); }
        }
    
        public static readonly DependencyProperty ReportNameProperty = DependencyProperty.Register("ReportName",
            typeof(string), typeof(ExportableGridView), new PropertyMetadata("Report", new PropertyChangedCallback(OnReportNameChanged)));
    
        public static void OnReportNameChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ExportableGridView control = sender as ExportableGridView;
            control.titleTextBlock.Text = e.NewValue as string;
        }
    
    #endregion ReportName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class grades that I need to check if a specific grade is
I have this setup in my models: class Author(models.Model): name = models.CharField(max_length=100) class Topic(models.Model):
If I have a simple class setup like this: class MyClass { private string
i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100)
I have following models setup in my Django application class School(models.Model): name = models.TextField()
I have the following setup. Class, say, Car that has a CarPart (belongsTo=[car:Car]). When
I have a page that is setup like this public partial class _Default :
The setup = I have this class, Transcript: class Transcript(models.Model): body = models.TextField('Body') doPagination
My problem is similar to: Problem creating NSManagedObject derived class I have setup a
I have this setup: class UsersController < InheritedResources::Base respond_to :html, :js, :xml, :json def

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.