public void Insert(int index, object model)
{
// Setup initial conditions.
jQueryObject insertBefore = InsertBefore(index);
// Construct the list-item control.
IView view = CreateItem(model);
IListItemView listItemView = view as IListItemView;
// Insert the containing DIV.
jQueryObject div = view.Container;
if (insertBefore == null)
{
div.AppendTo(Container);
}
else
{
div.InsertBefore(insertBefore);
}
// Store values.
itemViews.Add(view);
// Wire up events.
if (listItemView != null) div.Click(delegate(jQueryEvent e) { OnItemClick(e, listItemView); });
INotifyPropertyChanged observableView = view as INotifyPropertyChanged;
if (observableView != null) observableView.PropertyChanged += OnViewPropertyChanged;
}
#endregion