Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WeatherBotv4App - ConversationViewModel.cs
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows.Input;
using WeatherBotv4App.Helpers;
using WeatherBotv4App.Models;
using WeatherBotv4App.Services;
using Xamarin.Forms;
namespace WeatherBotv4App.ViewModels
public class ConversationViewModel : BaseViewModel
DirectLineService service;
public ObservableCollection<Message> Messages { get; set; }
private string _query;
public string Query
get { return _query; }
set { SetProperty(ref _query, value); }
public ICommand SendQueryCommand { get; private set; }
public ConversationViewModel()
service = new DirectLineService(Constants.BotUser);
Messages = new ObservableCollection<Message>();
SendQueryCommand = new Command(SendMessage);
async Task StartConversation() => await service.GetMessages(Messages);
void SendMessage()
if (!string.IsNullOrWhiteSpace(_query))
var user = service.Account.Name.ToUpper();
var message = new Message(_query, user);
Query = string.Empty;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.