Skip to content

Commit

Permalink
Merge pull request #31 from jdunlap/master
Browse files Browse the repository at this point in the history
Clearing items in a DarkDropDown does not clear the menu
  • Loading branch information
RobinPerris authored Aug 8, 2020
2 parents 79db58c + be8cbad commit 3f2b9bc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions DarkUI/Collections/ObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ protected virtual void Dispose(bool disposing)
ItemsRemoved(this, new ObservableListModified<T>(new List<T> { item }));
}

public new void Clear()
{
ObservableListModified<T> removed = new ObservableListModified<T>(this.ToList<T>());
base.Clear();

if (removed.Items.Count() > 0 && ItemsRemoved != null)
ItemsRemoved(this, removed);
}

#endregion
}
}
6 changes: 6 additions & 0 deletions DarkUI/Controls/DarkDropdownList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ private void Items_CollectionChanged(object sender, NotifyCollectionChangedEvent
}
}

if (e.Action == NotifyCollectionChangedAction.Reset)
{
_menu.Items.Clear();
SelectedItem = null;
}

ResizeMenu();
}

Expand Down
6 changes: 3 additions & 3 deletions DarkUI/Controls/DarkTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,16 +566,16 @@ private void UpdateNodes()
if (IsDragging)
return;

ContentSize = new Size(0, 0);

if (Nodes.Count == 0)
return;

var yOffset = 0;
var isOdd = false;
var index = 0;
DarkTreeNode prevNode = null;

ContentSize = new Size(0, 0);


for (var i = 0; i <= Nodes.Count - 1; i++)
{
var node = Nodes[i];
Expand Down

0 comments on commit 3f2b9bc

Please sign in to comment.