Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
Writing code!

Daniel Hindrikes dhindrik

😎
Writing code!
View GitHub Profile
View Bindings_StaticData.xaml
<CarouselView ItemSource="{Binding Persons, Mode=OneTime}">
<CarouselView.ItemTemplate>
<DataTemplate x:DataType="models:Person">
<Grid RowDefinitions="*, 30">
<Image Source="{Binding Photo, Mode=OneTime}" />
<Label Grid.Row="1" Text="{Binding Name Mode=OneTime}" />
</Grid>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
View Bindings_StaticData.cs
public List<Person> {get; set;} = new List<Person>()
{
new Person() {Name = "Daniel Hindrikes", Photo="daniel.png"},
new Person() {Name = "Satya Nadella", Photo="satya.png"}
};
View Bindings_Commands.xaml
<Button Text="Create" Command="{Binding Create, Mode=OneTime}" />
View Bindings_Command.cs
public ICommand Create => new TinyCommand(async() => {
await CreatePerson();
});
View Bindings_CollectionView.xaml
<CollectionView ItemSource="{Binding Items}">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="models:Person">
<StackLayout>
<Label Text="{Binding Name, Mode=OneTime}" />
<Label Text="{Binding Email, Mode=OneTime}" />
<label Text="{Binding Count}" />
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
View UseButton.xaml
<controls:Button CornerRadius="10" AnimationScale="0.95">
<Label Text="Save" HorizontalOptions="Center" />
</controls:Button>
<controls:Button CornerRadius="10" AnimationScale="0.95">
<StackLayout Orientation="Horizontal" Spacing="10" HorizontalOptions="Center">
<Image Source="apple.png" />
<Label Text="Sign in with Apple" HorizontalOptions="Center" />
</StackLayout>
</controls:Button>
View Button.cs
public class Button : PancakeView
{
public static BindableProperty CommandProperty = BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(Button));
public static BindableProperty CommandParameterProperty = BindableProperty.Create(nameof(CommandParameter), typeof(object), typeof(Button));
public ICommand Command
{
get => (ICommand)GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}
View RatingControl.cs
#nullable enable
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.Forms.Shapes;
namespace ShapeDemo.Controls
{
public class RatingControl : StackLayout
{