views:

150

answers:

2

I know I am missing something obvious but I can't seem to implement ObservableCollection in my class below. IE it won't show up in intellsense. Can someone please let me know what I am missing.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.ObjectModel;
using System.Reflection;
using System.ComponentModel;

namespace MyBTOList
{
public class InventoryListBTO : List<InventoryBTO>
{
    /// <summary>
    /// Get all inventory records from local database
    /// </summary>
    /// <returns></returns>
    public static InventoryListBTO GetAllInventoryRecords()
    {
        return GetInventoryListBO(Inventory.GetAllInventoryRecordsDb());
    }
 }

 public class InventoryBTO : INotifyPropertyChanged
 {

 }
+2  A: 

If you are using .NET 3.0 or 3.5 SP1 ObservableCollection is in WindowsBase.dll. In 4.0, it is in System.dll.

Richard Hein
Thanks, this was it. I forgot that reference doesn't get added with class libraries automatically.
+1  A: 

ObservableCollection lives in System.Collections.ObjectModel namespace. If you have included the right assemblies(which should be right by default) then it shouldn't be a problem.

One thing with generic types in VS Intellisense is that the IDE won't prompt you to include the right namespace until you fully type the generic arguments.

At this point, if you right click, the Resolve context menu wouldn't be there.

ObservableCollection

Once you fill in the generic arguments:

ObservableCollection<int>

Resolve context menu will be available and you can either add using System.Collections.ObjectModel; or modify ObservableCollection<int> to System.Collections.ObjectModel.ObservableCollection<int>.

Perhaps that's what you were seeing?

Igor Zevaka