Class MessageBase
Represents a base class which contains the functionality for all the message types in SfChat.
Implements
Namespace: Syncfusion.XForms.Chat
Assembly: Syncfusion.SfChat.XForms.dll
Syntax
public abstract class MessageBase : BindableObject, IMessage
Constructors
MessageBase()
Initializes a new instance of the MessageBase class.
Declaration
public MessageBase()
Fields
AuthorProperty
Identifies the Author Xamarin.Forms.BindableProperty.
Declaration
public static readonly BindableProperty AuthorProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
DataProperty
Identifies the Data Xamarin.Forms.BindableProperty.
Declaration
public static readonly BindableProperty DataProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
DateTimeProperty
Identifies the DateTime Xamarin.Forms.BindableProperty.
Declaration
public static readonly BindableProperty DateTimeProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
HideAfterSelectionProperty
Identifies the HideAfterSelection Xamarin.Forms.BindableProperty.
Declaration
public static readonly BindableProperty HideAfterSelectionProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
SuggestionsProperty
Identifies the Suggestions Xamarin.Forms.BindableProperty.
Declaration
public static readonly BindableProperty SuggestionsProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Properties
Author
Gets or sets the information about the author of a message.
Declaration
public Author Author { get; set; }
Property Value
Type |
---|
Author |
Data
Gets or sets the data object of this message.
Declaration
public object Data { get; set; }
Property Value
Type |
---|
System.Object |
DateTime
Gets or sets the date time details when the message was created.
Declaration
public DateTime DateTime { get; set; }
Property Value
Type |
---|
System.DateTime |
HideAfterSelection
Gets or sets a value indicating whether the message content like card, date picker, time picker, calendar should be hidden after user selects a card, date or time from the message.
Declaration
public bool HideAfterSelection { get; set; }
Property Value
Type |
---|
System.Boolean |
IsMessageContentHiddenAfterSelection
Gets or sets a value indicating whether the message content like card, date picker, time picker, is hidden after user selects a card, date or time from the message.
Declaration
public bool IsMessageContentHiddenAfterSelection { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
This property is meant for internal purposes only and should not be handled in application. Upon implementing the interface only add a getter and setter for the property without any other code logic implementation.
IsSuggestionViewHiddenAfterSelection
Gets or sets a value indicating whether suggestion view is hidden after a suggestion item is selected.
Declaration
public bool IsSuggestionViewHiddenAfterSelection { get; set; }
Property Value
Type |
---|
System.Boolean |
Suggestions
Gets or sets the list of items to be displayed as response to a user message, the orientation of the items, its spacing and wrapping behavior. The suggestions will be displayed directly below the message as part of the message view.
Declaration
public ChatSuggestions Suggestions { get; set; }
Property Value
Type |
---|
ChatSuggestions |
Examples
The following code example demonstrates how to add suggestions to display directly below the message as part of the message view.
using Syncfusion.XForms.Chat;
using System.Collections.ObjectModel;
using Xamarin.Forms;
namespace ChatDemo
{
public class SfChatDemo : ContentPage
{
SfChat sfChat;
ObservableCollection<object> messageCollection;
public SfChatDemo()
{
sfChat = new SfChat();
messageCollection = new ObservableCollection<object>();
ChatSuggestions suggestions = new ChatSuggestions();
ObservableCollection<Suggestion> items = new ObservableCollection<Suggestion>();
items.Add(new Suggestion() { Text = "Audi" });
items.Add(new Suggestion() { Text = "BMW" });
suggestions.Items = items;
suggestions.ItemSpacing = 15;
suggestions.Orientation = SuggestionsOrientation.Horizontal;
TextMessage message = new TextMessage();
message.Text = "Please select your favorite car";
message.Author = new Author() { Name = "Andrea", Avatar = "Andrea.png" };
message.Suggestions = suggestions;
messageCollection.Add(message);
sfChat.Messages = messageCollection;
this.Content = sfChat;
}
}
}
<?xml version = "1.0" encoding="utf-8" ?>
<ContentPage xmlns = "http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sfchat="clr-namespace:Syncfusion.XForms.Chat;assembly=Syncfusion.SfChat.XForms"
xmlns:local="clr-namespace:Chat"
mc:Ignorable="d"
x:Class="Chat.SfChatDemo">
<ContentPage.BindingContext>
<local:ViewModel x:Name="viewModel" />
</ContentPage.BindingContext>
<ContentPage.Content>
<sfchat:SfChat x:Name="Sfchat">
<sfchat:SfChat.Messages>
<sfchat:TextMessage
Author="{Binding IncomingMessageAuthor,Source={x:Reference viewModel}}"
Suggestions="{Binding ChatSuggestions,Source={x:Reference viewModel}}"
Text=""Please select your favorite car">
</sfchat:TextMessage>
</sfchat:SfChat.Messages>
</sfchat:SfChat>
</ContentPage.Content>
</ContentPage>
Methods
Dispose()
Disposes the managed resources.
Declaration
public virtual void Dispose()