Created
May 20, 2020 19:38
-
-
Save andreas-nesheim/95522e21ad219252c4d02723d665a643 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>CollectionView Template</Title> | |
<Author>Andreas Nesheim</Author> | |
<Description>Snippet for creating a simple CollectionView with a bindable ItemsSource</Description> | |
<Shortcut>cv</Shortcut> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal Editable="true"> | |
<ID>ListName</ID> | |
<ToolTip>Name of the ItemsSource to bind to</ToolTip> | |
<Default>Items</Default> | |
<Function> | |
</Function> | |
</Literal> | |
<Literal Editable="true"> | |
<ID>PropertyName1</ID> | |
<ToolTip>Image source in the ItemsSource to bind to</ToolTip> | |
<Default>ImageUrl</Default> | |
<Function> | |
</Function> | |
</Literal> | |
<Literal Editable="true"> | |
<ID>PropertyName2</ID> | |
<ToolTip>Name of the property in the ItemsSource to bind to</ToolTip> | |
<Default>Name</Default> | |
<Function> | |
</Function> | |
</Literal> | |
<Literal Editable="true"> | |
<ID>PropertyName3</ID> | |
<ToolTip>Name of the property in the ItemsSource to bind to</ToolTip> | |
<Default>Location</Default> | |
<Function> | |
</Function> | |
</Literal> | |
</Declarations> | |
<Code Language="XAML"> | |
<![CDATA[<CollectionView ItemsSource="{Binding $ListName$}"> | |
<CollectionView.ItemTemplate> | |
<DataTemplate> | |
<Grid Padding="10"> | |
<Grid.RowDefinitions> | |
<RowDefinition Height="Auto" /> | |
<RowDefinition Height="Auto" /> | |
</Grid.RowDefinitions> | |
<Grid.ColumnDefinitions> | |
<ColumnDefinition Width="Auto" /> | |
<ColumnDefinition Width="Auto" /> | |
</Grid.ColumnDefinitions> | |
<Image Grid.RowSpan="2" | |
Source="{Binding $PropertyName1$}" | |
Aspect="AspectFill" | |
HeightRequest="60" | |
WidthRequest="60" /> | |
<Label Grid.Column="1" | |
Text="{Binding {Binding $PropertyName2$}" | |
FontAttributes="Bold" /> | |
<Label Grid.Row="1" | |
Grid.Column="1" | |
Text="{Binding {Binding $PropertyName3$}" | |
FontAttributes="Italic" | |
VerticalOptions="End" /> | |
</Grid> | |
</DataTemplate> | |
</CollectionView.ItemTemplate> | |
</CollectionView>]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment