Make working with Xamarin.Forms just a little bit easier.
See Industrious.ToDo for usage examples in something resembling a real application.
Automatically set the input focus to a particular view when a condition becomes true.
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:forms="clr-namespace:Industrious.Forms;assembly=Industrious.Forms"
x:Class="SampleClass">
<StackLayout>
<Entry
Text="{Binding Title}"
forms:AutoFocusBehavior.FocusWhen="{Binding ShouldFocusTitle}" />
</StackLayout>
</ContentView>
A constant can also be used to always set the input focus when the form is loaded.
<Entry
Text="{Binding Title}"
forms:AutoFocusBehavior.FocusWhen="True" />
A shortcut for binding boolean properties on a Xamarin.Forms view to a non-boolean value on the view model. See BooleanConverter for info on how values are interpreted. Supports the use of "!" to negate the value.
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:forms="clr-namespace:Industrious.Forms;assembly=Industrious.Forms"
x:Class="SampleClass">
<StackLayout>
<StackLayout
x:Name="MainLayout"
IsVisible="{forms:BooleanBinding ItemCount}">
<!-- main content goes here -->
</StackLayout>
<StackLayout
x:Name="EmptyCollectionLayout"
IsVisible="{forms:BooleanBinding !ItemCount}">
<!-- show this view when there are no items in the collection -->
</StackLayout>
</StackLayout>
</ContentView>
Converts most types into a boolean value using C-style rules: null and zero values are interpreted as false
; anything else evaluates as true
. Convenient for those times you'd like to bind an object's visibility to the existence of an object.
public class MyViewModel
{
public Object SomeObjectProperty { get; set; }
}
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:forms="clr-namespace:Industrious.Forms;assembly=Industrious.Forms"
x:Class="SampleClass">
<StackLayout>
<Label
Text="The object exists"
IsVisible="{Binding SomeObjectProperty, Converter={forms:BooleanConverter}}" />
</StackLayout>
</ContentView>
Converts most types into a boolean value following the same logic as BooleanConverter, but inverts the results: null and zero values are interpreted as true
, anything else evaluates as false
.
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:forms="clr-namespace:Industrious.Forms;assembly=Industrious.Forms"
x:Class="SampleClass">
<StackLayout>
<Label
Text="The object does not exists"
IsVisible="{Binding SomeObjectProperty, Converter={forms:BooleanInverseConverter}}" />
</StackLayout>
</ContentView>
- Website - https://industriousone.com
- Twitter - @industrious