jc_lvngstn
Topic Author
Posts: 34
Joined: 23 Sep 2013, 03:03

Property 'Items' not registered for type 'ContainerData'

07 Oct 2013, 17:03

I'm getting this error when trying to raise the property changed event.
ContainerData is my class which ultimately inherits from BaseComponent. It has the property Items, which is a list of ItemData (ItemData also inherits from BaseComponent). I set the datacontext to an instance of ContainerData, in my start function.


Here is my xaml:
<ListView ItemsSource="{Binding Path=Items}">
   <ListView.View>
	  <GridView>
		 <GridViewColumn Width="200" Header="Item" DisplayMemberBinding="{Binding Path=ItemName}" />
		 <GridViewColumn Header="Quality"/>
		 <GridViewColumn Width="60" Header="Amount"/>
		 <GridViewColumn Header="Damage"/>
	  </GridView>
   </ListView.View>				
</ListView>
As you can see, the listview binds to my items collection, and the first column displays the ItemName. Property notification works fine with simple properties, but seems to have issues when I add items to the collection, via this:
		public void AddItem(ItemData item)
		{
			_Items.Add(item);
			NotifyPropertyChanged("Items");
		}

My ItemData item also has property notification. Anyway...a little confused as to why this is failing, any direction is most appreciated :)
 
User avatar
sfernandez
Site Admin
Posts: 3222
Joined: 22 Dec 2011, 19:20

Re: Property 'Items' not registered for type 'ContainerData'

07 Oct 2013, 23:34

Have you defined a public C# Property named Items in your ContainerData class?
What is the type of the property?
 
jc_lvngstn
Topic Author
Posts: 34
Joined: 23 Sep 2013, 03:03

Re: Property 'Items' not registered for type 'ContainerData'

07 Oct 2013, 23:56

I tried it with a List
		public List<ItemData> Items
		{
			get { return _Items; }
			set
			{
				_Items = value;
				NotifyPropertyChanged("Items");
			}
		}
For now, I'm doing this:
ItemCollection itmCollection = _ItemsListBox.GetItems();
itmCollection.Add(itemData);
Which is working quite well so far. Would using a Collection be better for notification?
 
User avatar
sfernandez
Site Admin
Posts: 3222
Joined: 22 Dec 2011, 19:20

Re: Property 'Items' not registered for type 'ContainerData'

08 Oct 2013, 00:08

I'm afraid using Collection is the only possibility right now. You should have something like this:
      private Noesis.Collection _Items;
      public Noesis.Collection Items
      {
         get { return _Items; }
         set
         {
            if (_Items != value)
            {
               _Items = value;
               NotifyPropertyChanged("Items");
            }
         }
      }
 
jc_lvngstn
Topic Author
Posts: 34
Joined: 23 Sep 2013, 03:03

Re: Property 'Items' not registered for type 'ContainerData'

08 Oct 2013, 00:11

Sounds great. Thanks for all of your support, sfernandez!

Who is online

Users browsing this forum: Semrush [Bot] and 2 guests