神刀安全网

Michael Ridland: 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:BindablePickerItemsSource="{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:AdvancedFrameCorners="left" CornerRadius="10" InnerBackground="Blue" OutlineColor="Red">     <LabelText="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:SegmentedButtonGroupOnColor="Blue" OffColor="White" SelectedIndex="{Binding SelectIndex, Mode=TwoWay}"> <fe:SegmentedButtonGroup.SegmentedButtons>   <fe:SegmentedButtonTitle="Button 1"/>   <fe:SegmentedButtonTitle="Button 2"/>   <fe:SegmentedButtonTitle="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:InverseBooleanConverterx:Key="InverseConverter"/>     </ResourceDictionary> </ContentPage.Resources>   <ButtonText="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 readthis blog.

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

TappedGestureAttached

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

<ImageSource="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

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Michael Ridland: FreshEssentials for Xamarin.Forms – The must-have nuget for Forms

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址