Skip to content

Instantly share code, notes, and snippets.

@winstongubantes
Created February 9, 2017 16: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 winstongubantes/9cc621b267666f95de11301aa3856f89 to your computer and use it in GitHub Desktop.
Save winstongubantes/9cc621b267666f95de11301aa3856f89 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using ConversationApp.Models;
using Xamarin.Forms;
namespace ConversationApp.ViewModels
{
public class ConversationPageViewModel : INotifyPropertyChanged
{
private ObservableCollection<Message> _messages;
private string _userName;
private string _textMessage;
private ICommand _sendMessageCommand;
public event PropertyChangedEventHandler PropertyChanged;
public ConversationPageViewModel()
{
Messages = new ObservableCollection<Message>();
Messages.Add(new Message {Messagetext = "Hello", Sender = "Sender", UserImageUrl = "me_user.png"});
}
public ObservableCollection<Message> Messages
{
get { return _messages; }
set
{
_messages = value;
OnPropertyChanged("Messages");
}
}
public string UserName
{
get { return _userName; }
set
{
_userName = value;
OnPropertyChanged("UserName");
}
}
public string TextMessage
{
get { return _textMessage; }
set
{
_textMessage = value;
OnPropertyChanged("TextMessage");
}
}
public ICommand SendMessageCommand
{
get { return _sendMessageCommand = _sendMessageCommand ?? new Command(() =>
{
}); }
}
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment