Skip to content

Instantly share code, notes, and snippets.

@juucustodio

juucustodio/MainPage.xaml

Last active Dec 15, 2017
Embed
What would you like to do?
Example of Chat in Xamarin.Forms applications - http://julianocustodio.com/chat
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:DemoChat;assembly=DemoChat"
x:Class="DemoChat.Views.MainPage" Title="Chat">
<ContentPage.Resources>
<ResourceDictionary>
<local:SelectorDataTemplate x:Key="MessageTemplateSelector"/>
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView>
<Grid RowSpacing="0" ColumnSpacing="0" >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView
x:Name="MessagesListView"
ItemTemplate="{StaticResource MessageTemplateSelector}"
ItemsSource="{Binding ListMessages}"
HasUnevenRows="True" SeparatorVisibility="None" IsEnabled="True" Grid.Row="0"/>
<StackLayout Orientation="Horizontal" Grid.Row="1" BackgroundColor="White" VerticalOptions="EndAndExpand">
<Entry
HorizontalOptions="FillAndExpand"
Placeholder="Message"
Text="{Binding OutText}" Keyboard="Chat" Margin="4"/>
<Image Source="sendButton.png" WidthRequest="40" HeightRequest="40" Margin="4">
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding SendCommand}" />
</Image.GestureRecognizers>
</Image>
</StackLayout>
</Grid>
</ScrollView>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment