Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created May 26, 2018 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/fb4e05a1f33bb935dc0171fd999a20c0 to your computer and use it in GitHub Desktop.
Save icebeam7/fb4e05a1f33bb935dc0171fd999a20c0 to your computer and use it in GitHub Desktop.
XamarinFaceBot: PaginaBot.xaml.cs
using System;
using System.Collections.ObjectModel;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XamarinFaceBot.Helpers;
using XamarinFaceBot.Modelos;
using XamarinFaceBot.Servicios;
namespace XamarinFaceBot.Paginas
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PaginaBot : ContentPage
{
ServicioBotDirectLine bot;
ObservableCollection<Mensaje> listaMensajes;
public PaginaBot ()
{
InitializeComponent ();
bot = new ServicioBotDirectLine(Constantes.BotUser);
listaMensajes = new ObservableCollection<Mensaje>();
lsvMensajes.ItemsSource = listaMensajes;
bot.ObtenerMensajes(listaMensajes);
}
public void btnEnviar_Clicked(object sender, EventArgs e)
{
var texto = txtMensaje.Text;
if (texto.Length > 0)
{
txtMensaje.Text = "";
var mensaje = new Mensaje(texto, bot.Cuenta.Name);
listaMensajes.Add(mensaje);
bot.EnviarMensaje(texto);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment