Created
February 9, 2017 16:23
-
-
Save winstongubantes/9cc621b267666f95de11301aa3856f89 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
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