Hi there!
So, I've been working with putting a Database into my Kanban project and I ended up getting everything working. I also checked out the example you gave someone on thread
134560.
So, I have an issue where when I add in and read the KanbanModels from the database and add it to a specific assignee (in swimlane view), the card does not show up, but it gets added to the count of items for the column? So, I stepped through the program completely and checked to make sure all of the calls and variables and types were correct, but I was unable to fix it.
I even went off of your example you gave on that thread with no luck. I created the ObservableCollection<KanbanModel> and did the same setup but with no luck, even by setting the KanabanControl.ItemsSource equal to the collection and I even tried to manually Bind from Xaml, also with no luck.
Currently, I switched to the Basic UI view by taking away the Assignee parameter, and it works perfectly....? All I did was take out the Assignee property within the model creation and all to go back to the UI without swimlane.
I was adding into the db like this, where cols are setup as (ID, Title, Description, Category, ColorKey, Tags) and ID is the primary key which auto increments:
db.Open();
SqliteCommand insertCommand = new SqliteCommand();
insertCommand.Connection = db;
// Use parameterized query to prevent SQL injection attacks
insertCommand.CommandText = "INSERT INTO MyTable VALUES (NULL, @title, @desc, @categ, @colorKey, @tags);";
insertCommand.Parameters.AddWithValue("@title", title);
insertCommand.Parameters.AddWithValue("@desc", desc);
insertCommand.Parameters.AddWithValue("@categ", categ);
insertCommand.Parameters.AddWithValue("@colorKey", colorKey);
insertCommand.Parameters.AddWithValue("@tags", tags);
insertCommand.ExecuteReader();
db.Close();
I was getting the data from the db like this, though I've tried many different ways to get it to work and nothing helped, including how yours was setup. The code below is currently in the GetData function which returns the observable collection:
ObservableCollection<KanbanModel> tasks = new ObservableCollection<KanbanModel>();
// Get tasks and return the collection
using (SqliteConnection db =
new SqliteConnection("Filename=sqliteNewTest.db"))
{
db.Open();
SqliteCommand selectCommand = new SqliteCommand
("SELECT Id, Title, Description, Category, ColorKey, Tags from MyTable", db);
SqliteDataReader query = selectCommand.ExecuteReader();
// Query the db and get the tasks
while (query.Read())
{
KanbanModel row = new KanbanModel()
{
ID = query.GetString(0),
Title = query.GetString(1),
Description = query.GetString(2),
Category = query.GetString(3),
ColorKey = query.GetString(4),
Tags = query.GetString(5).Split(",") // Turn string of tags into string array, fills listview
};
tasks.Add(row);
}
db.Close();
}
return tasks;
Once GetData() returns, it's being set to the ItemSource of Kanban, i.e., kanbanControl.ItemsSource = DataAccess.GetData();
Just for the context again, I did go off of your example from the thread listed above, and had the ObservableCollection placed in the same area as you, but no luck :( Really wanted to use the Swimlane view both for appearances and to use myself after I'm finished with the program. If you'd like a copy of my project to test, I'll attach it but please let me know. Would love to get this issue figured out!
As I said, I did remove the Assignee property for the KanbanModels and that took it out of Swimlane view, which made things work fine. So, I just took it out of the table completely and as of right now I took away the option for the user to add their own Assignee. It was working perfectly before I started working with a database too.