Tuesday, May 16, 2017

Xamarin Forms: GridView Control

So I was busy with my nightly dev sessions, building the next big startup product [read side-project], when I ran into what I thought was a fairly simple requirement:

I wanted to show a list of stuff in a template of an item that was in a ListView.

image

Turns out hosting a ListView inside a ListView doesn’t work out so well. Besides it being a rocket ship when I only needed a small car, it just doesn’t work. You see, the ListView has some sizing issues that doesn’t make it a great candidate for said scenario.
Now unless I’m missing something here (which is quite likely), I couldn’t really find any Xamarin Forms control that hosted a simple list of items, without needing properties like grouping, selecteditem etc.

After some searching on the interwebs, I came across this really simple example of what I needed from Chase Florell. (I’ve since happened upon this contribution by Daniel Luberda, which also looks pretty decent). It met my very basic requirement of a simple list of stuff, minus some handy bindings, so I set out to edit the code.

You can see the results (source code and sample project) here

Basically, you can create a tile-like layout with N many columns. The content of the “tiile” can be any template you like.

Sample Xaml:

image

The control also supports ItemTappedCommand, which will call a delegate and pass the selected data item as a parameter.

The default for MaxColumns is 1 – which will give you a simple list as illustrated at the top of the post. More columns will give you something like:

imageimage

I wouldn’t use this implementation for more than about 20 or so data items, as there is no cell recycling as you would get in a ListView, but for very basic scnenarios, I’ve found this simple implementation good enough.

As a side note, I’ve also moved the previously mentioned Bindable IsVisible ToolbarItem control to the linked repo, in addition to a few other very basic controls like an Editor that expands as you type, a ListView with ItemClickCommand and default RecycleElement mode, a floating label pattern Entry (pending), and a simple WrapLayout (which I’ve used in combination with an AddStringEntry to create a Tag List)  - which I’ll cover in subsequent posts as I find the time.

Xamarin FTW Smile

Saturday, March 11, 2017

Essential Visual Studio 2017 Tools & Extensions

Web Essentials 2017
Wrapper for many handy extensions such as File Nesting, Image Optimizer, Markdown Editor, Open Command Line & HTML Tools

Productivity Power Tools 2017
Another wrapper for extensions like Ctrl+Click GoTo Navigation, Power Commands for Visual Studio & Copy As Html

XAML Styler 
Format your XAML on save - consistent and readble XAML Style implementations

CodeMaid
Cleanup and format your code. Multiple language support

NUnit 3 Test Adapter
Run NUnit tests in Visual Studio
...also consider xUnit unit testing

Cloud Explorer for Visual Studio 2017
View your cloud resources, inspect properties, and perform key developer actions from within Visual Studio

ResXManager
Central access to all ResX-based string resources in your solution

..any other essential extensions you can't do without? Share in the comments below.





Saturday, March 4, 2017

Xamarin Forms: ToolbarItem with Bindable IsVisible Property

It's fairly typical for toolbar items to change depending on the state of the model that the view is bound to (quite another thing if it's considered good UX).

Unfortunately Xamarin Forms doesn't have an IsVisible property on it's ToolbarItem control, so I had to hunt for a sample implementation.

A found this handy thread on the Xamarin forums.
Basically create a custom control that inherits from ToolbarItem, add a bindable IsVisible property, and add /remove the toolbar items as the property changes.

I made some minor modifications, and added the source code here

Happy Coding :)



Daily Links 4 Mar 2017

The 12 Factor App

Building Single Page Applications on ASP.NET Core with JavaScriptServices

Realtime Databases with the Realm Mobile Platform

Penny Pinching in the Cloud: Running and Managing LOTS of Web Apps on a single Azure App Service

Xamarin Forms ListView Grouping

Xamarin.Forms Android Selected & Unselected Tab Colors

Xamarin Forms Tab Badge

Azure App Service Secrets and Web Site Hidden Gems

What is scope and closure in JavaScript?

Writing Jasmine unit tests in ES6

Getting Started With WebAssembly in Node.js

Parsing And Serializing Large Objects Using JSONStream In Node.js

Azure App Service Authentication in an ASP.NET Core Application