Welcome back to the The Globe In My BucketList Application (TGIMBA) Windows Presentation Foundation (WPF) client creation. Tonight will be about cloning the bucket list item view’s clickable list control for the search results view.
First thing I did was to remove the ‘shared’ components to a utility class. For me, the Don’t Repeat Yourself (DRY) is one the most important software development practices. Initially, I tried a base class. But for some reason I didn’t figure out, inserting my base class between the .NET UserControl class and my view class didn’t work. So, I created a Utilities class in the root of the WPF client. The entry point is the array of bucket list items and the output is the List<Button> collection of clickable bucket list items. Specifically:
The view code behind looks like this where it calls the utility class (just like the bucket list view code behind) with the bucket list array from the model and then displays the resulting List<Button> collection in the ItemControl. Specifically:
Adding the markup was almost identical to the bucket list view:
To see in action:
- follow the previous instructions to login and get to the search screen, enter a search term and click ‘Search’
- click on an item and the prompt will display what you selected.
What is up next is taking this selection from the bucket list item AND search results view to populate the edit view functionality.