FreshEssentials for Xamarin.Forms – The must-have nuget for Forms

Ah this is one I’ve been wanting to do for a long time and I’m pretty excited about it. We use it everyday, as it’s really useful.

FreshEssentials for Xamarin.Forms has ONLY the most common elements you need for Xamarin.Forms. It’s contains the elements you need in almost every project and nothing more, things like BindablePicker, SegementedButtons, InverseBooleanConverter, TappedGestureAttached, ListViewItemTappedAttached and not much more. It’s the lightweight essentials.

Why?

Because it’s awesome and nothing else solves this problem yet. For the majority of projects there’s some missing essential pieces to the Xamarin.Forms puzzle, what I wanted to build was a nuget that filled the gaps but ONLY the essential gaps. These are code snippets I’ve been putting in the majority of my Xamarin.Forms projects, the components are stable and used regularly. These codes snippets include a BindablePicker and InverseBooleanConverter, who doesn’t use them in a project. Most people just copy them from project to project, XLabs had the idea to solve this issue but now it’s blow out and is normally too large for most Xamarin.Forms projects. Just to note, I’m a contributor to XLabs and was one one of the first to contributors but with the direction it’s now taken I’m not sure if anyone wants to maintain it, the monolith it is means it’s hard to maintain.

How to use?

nuget all the things…. Primarily you can get FreshEssentials from nuget.

https://www.nuget.org/packages/FreshEssentials/1.0.0

The code can be found on github and there’s also a sample project.

FreshEssentials on github(https://github.com/XAM-Consulting/FreshEssentials)

FreshEssentials sample on github (https://github.com/XAM-Consulting/FreshEssentialsSample)

BindablePicker

Ok so who doesn’t need a BindablePicker in a Xamarin.Forms project?

BindablePicker inherits from Xamarin.Forms.Picker, you can binding data to ItemSource as Items, and also can set which property you want to display via DisplayProperty.

If you want to use it in XAML, you need to include the namespace first.

xmlns:fe="clr-namespace:FreshEssentials;assembly=FreshEssentials"
<fe:BindablePicker ItemsSource="{Binding MyCars}" SelectedItem="{Binding SelectedCar}" DisplayProperty="MakeAndModel" Title="Select..." />

AdvancedFrame (flexible rounded corners)

This is primary used for the SegmentedButtonGroup, it gives you more flexibility on the corner radius in the Frame. AdvancedFrame inherits from Frame, you can set corner type via Corners(There are only four type, left, right, all, none), you can also set CornerRadius and InnerBackground color

<fe:AdvancedFrame Corners="left" CornerRadius="10" InnerBackground="Blue" OutlineColor="Red" >
    <Label Text="Corners is left, CornerRadius is 10, InnerBackground is Blue" TextColor="White"/>
</fe:AdvancedFrame>

SegmentedButtonGroup

This is one that most people ask for in their first project, normally people fail to implement the segmented button in XF and crosss platform. I hope with this control people will be able to use it more often.

SegmentedButtonGroup is like iOS Segmented Controls, you can binding SelectedIndex for it

<fe:SegmentedButtonGroup OnColor="Blue" OffColor="White" SelectedIndex="{Binding SelectIndex, Mode=TwoWay}">
<fe:SegmentedButtonGroup.SegmentedButtons>
  <fe:SegmentedButton Title="Button 1"/>
  <fe:SegmentedButton Title="Button 2"/>
  <fe:SegmentedButton Title="Button 3"/>
</fe:SegmentedButtonGroup.SegmentedButtons>
</fe:SegmentedButtonGroup>

InverseBooleanConverter

Ah the amount of times people have copied this code into their project… not anymore….

<ContentPage.Resources>
    <ResourceDictionary>
         <fe:InverseBooleanConverter x:Key="InverseConverter" />
    </ResourceDictionary>
</ContentPage.Resources>

<Button Text="Click Me" IsVisible="{Binding ShowButton, Converter={StaticResource InverseConverter}}" />

ListViewItemTappedAttached

This ones is definately a project favorite, if you’re not sure what it does be sure to take a look at the samples and read this blog.

<ListView ItemsSource="{Binding MyCars}" fe:ListViewItemTappedAttached.Command="{Binding ItemTapCommand}">

TappedGestureAttached

The easiest way to add a tap gesture to your controls.

<Image Source="xamconsulting.png" fe:TappedGestureAttached.Command="{Binding ImageTappedCommnad}" />

 

That’s it! All we need. Please be sure to take a look at the samples, you can clone from github or download the zip.

Please let me know how it goes.

Thanks

Michael

 

5 Responses

  1. Excellent work, thank you – perhaps worth finding all Xamarin forum posts about each of those subjects and adding a link to this blog… I know you would be thanked time and time again! I wish this existed 6 months ago 😉

    Kudos to you
    Rob.

  2. Hi Michael, I\’ve just tried using the BindablePicker version 2.01 and if I change the items source in the ViewModel after the Picker has been rendered then the items in the Picker list aren\’t changed. Is that expected behaviour? I\’ve tried with both an ObservableCollection and List.

    1. Malcolm, we don’t track if an individual item has changed or use ObservableCollection we only update if a new list is assigned. This is at the moment but might add the feature in the future.

      What you can do now is Raise that the whole property was changed.

  3. I am trying to implement this plugin and it worked if I am using a hard coded list however if I populate the binded list using an async method nothing shows up. How can I achieve this?

Leave a Reply to Rafael Cancel reply