Welcome back to the The Globe In My BucketList Application (TGIMBA) Windows Presentation Foundation (WPF) client creation. Tonight will be about making the bucket list view clickable so we can launch the edit window.
To make the list I wanted, I looked around and found the ItemControl. Starting with the example in reference #3, I was able to create a version of the control that took a dynamically loaded list of buttons for each item. This is what the xaml looks like:
The next step was to dynamically load them. This was accomplished by using the same technique in reference #3 from the code behind. Additionally, I am storing the entire data object (a string) in the button’s CommandParameter. When the button is clicked, I will retrieve this to populate the edit window. Specifically:
NOTE: The breakpoint shows the button’s CommandParameter where I am storing the full bucket list item data.
If you look at the bucket click event I have attached to each item, I am able to pull the database right back out by casting the sender argument. Specifically:
To see it in action:
- Use the steps in my previous blog posts to get the the bucket list view
- Click on an item and the prompt will show you the item you selected
I will take this entry and in my next blog post, populate the Edit View and allow the user to updated it and save it to the database. If time allows, I will add this same code to the search results so any search will also allow the user to edit from that view as well in the same post. If not, I will include it and a delete function (on the same Edit View) in the post following that.