Closed KayOpper closed 1 year ago
Hi,
looks like you're right. I've added your use case to the example app and get the same result. I'll have a look at it ;)
I think I fixed the issue. Will release a new version of the Nuget soon
Hello.
Thanks for dealing with my issue very fast. Now I am still waiting for the update version on NuGet. It should also always contain the correct property value for the CardCount, especially after Items.Refresh()
Thanks for reminding me! Sorry I lost track of this... I'll release it now ;)
Here you go: https://www.nuget.org/packages/WPF-Kanban/2.0.2
Please let me know it this fixes the issue for you ;)
Yes, you solved it. Thank you.
Sorry, it is only fixed half ;-). After Items.Refresh(), the CardCount property value of each column returns zero even if they contain cards. The correct CardCount is shown in the header of the coulmns in the Kanbanboard but the property getter returns zero. Items.Refresh() is no longer necessary for me at the moment but it is still not correct.
Hey sorry to hear that! I was trying to reproduce your issue in the sample app, but wasn't able. This is what I was trying: https://github.com/KhaosCoders/wpf-kanban/commit/ba8d2a8cebc537e2318e1c24fa4a98f57fbc8ea1 But all the columns show the correct numbers after I hit the Refresh button. So you must be doing something else.
Can you please hand me an example with your issue?
Yes the columns show the correct value but the return value of the property getter is zero. This happens only direct after Items.Refresh(). I do something like this:
ordersKanbanBoard.Items.Refresh();
foreach (KanbanColumn column in ordersKanbanBoard.Columns)
{
if (column.CardCount == 0)
column.IsCollapsed = true;
else
column.IsCollapsed = false;
Console.WriteLine("Column {0} has {1} cards", column.ColumnValue, column.CardCount); // is always zero
}
Yes the columns show the correct value but the return value of the property getter is zero. This happens only direct after Items.Refresh(). I do something like this:
ordersKanbanBoard.Items.Refresh(); foreach (KanbanColumn column in ordersKanbanBoard.Columns) { if (column.CardCount == 0) column.IsCollapsed = true; else column.IsCollapsed = false; Console.WriteLine("Column {0} has {1} cards", column.ColumnValue, column.CardCount); // is always zero }
That's aktually smart to auto hide empty columns... I'll have a look. Maybe there should be a AutoHide
Property on the column, so you don't have to do this ;)
@KayOpper I guess what you're doing is not how the .NET Framework is supposed to work.
The call to Items.Refresh()
causes a Reset
of the cards collection (that's why all CardCount
properties are 0
). It also causes the layout to re-create the cards on the next render cycle. Since there is no pause between your call to Refresh
and the foreach loop, where the Dispatcher
could run a render cycle, the cards are not yet re-created and therefore the CardCount
is not yet updated. The UI is showing the correct counts, as the following render cycle updates the UI and creates the cards correctly.
Solution: Dispatcher with priority Loaded (one priority below Render)
kanBoard.Items.Refresh();
Dispatcher.BeginInvoke(new Action(() =>
{
foreach (KanbanColumn column in kanBoard.Columns)
{
column.IsCollapsed = column.CardCount == 0;
Console.WriteLine("Column {0} has {1} cards", column.ColumnValue, column.CardCount); // has correct value
}
}), System.Windows.Threading.DispatcherPriority.Loaded);
Ah okay. I understand. Then it is okay for me. Mainly, I was confused that the CardCount values from the UI and the property getter were not the same :-)
I've added a new AutoCollapse
property to the KanbanColumn
. I'll release a new version later today
Please close this issue if your issue has been resolved ;)
Hello.
I have several columns and swimlanes in my Kanbanboard, of course. If I delete a card via the context menu, it will be deleted from the observable collection successfully but it is still visible in the Kanbanboard. If I move then with the mouse over this card, I get a NullReferenceException from the CanDragCardEvent.
So I try to help myself with Items.Refresh(). This updates the view now but I get the next issue as I need the CardCount values of the columns. The correct CardCount is shown in the header of the coulmns in the Kanbanboard but the source code returns zero for all columns. This happens only after Items.Refresh().
So what I need, is to delete a card which should disappear from the Kanbanboard. After that, the source code should deliver the correct CardCount values of the columns. I hope you have some ideas how to fix this.
Regards