Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.