-
- jc_lvngstn
- Posts: 34
- Joined:
Property 'Items' not registered for type 'ContainerData'
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:
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:
My ItemData item also has property notification. Anyway...a little confused as to why this is failing, any direction is most appreciated
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:
Code: Select all
<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>
Code: Select all
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

-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: Property 'Items' not registered for type 'ContainerData'
Have you defined a public C# Property named Items in your ContainerData class?
What is the type of the property?
What is the type of the property?
-
- jc_lvngstn
- Posts: 34
- Joined:
Re: Property 'Items' not registered for type 'ContainerData'
I tried it with a List
For now, I'm doing this:
Which is working quite well so far. Would using a Collection be better for notification?
Code: Select all
public List<ItemData> Items
{
get { return _Items; }
set
{
_Items = value;
NotifyPropertyChanged("Items");
}
}
Code: Select all
ItemCollection itmCollection = _ItemsListBox.GetItems();
itmCollection.Add(itemData);
-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: Property 'Items' not registered for type 'ContainerData'
I'm afraid using Collection is the only possibility right now. You should have something like this:
Code: Select all
private Noesis.Collection _Items;
public Noesis.Collection Items
{
get { return _Items; }
set
{
if (_Items != value)
{
_Items = value;
NotifyPropertyChanged("Items");
}
}
}
-
- jc_lvngstn
- Posts: 34
- Joined:
Re: Property 'Items' not registered for type 'ContainerData'
Sounds great. Thanks for all of your support, sfernandez!
Who is online
Users browsing this forum: Semrush [Bot] and 2 guests