menu

Xamarin.Forms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class CardMessage - Xamarin.Forms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class CardMessage

    Represents a class which contains the functionalities for the card message in SfChat.

    Inheritance
    System.Object
    MessageBase
    TextMessage
    CardMessage
    Implements
    ICardMessage
    ITextMessage
    IMessage
    Inherited Members
    MessageBase.Author
    MessageBase.AuthorProperty
    MessageBase.Data
    MessageBase.DataProperty
    MessageBase.DateTime
    MessageBase.DateTimeProperty
    MessageBase.HideAfterSelection
    MessageBase.HideAfterSelectionProperty
    MessageBase.IsMessageContentHiddenAfterSelection
    MessageBase.IsSuggestionViewHiddenAfterSelection
    MessageBase.Suggestions
    MessageBase.SuggestionsProperty
    TextMessage.Text
    TextMessage.TextProperty
    Namespace: Syncfusion.XForms.Chat
    Assembly: Syncfusion.SfChat.XForms.dll
    Syntax
    public class CardMessage : TextMessage, ICardMessage, ITextMessage, IMessage
    Examples

    The following code example demonstrates how to add card message in SfChat control.

    using Syncfusion.XForms.Chat;
    using Xamarin.Forms;
    

    namespace ChatDemo { public class SfChatDemo : ContentPage { SfChat sfChat; public SfChatDemo() { sfChat = new SfChat();

            CardMessage cardMessage = new CardMessage();
            cardMessage.Text = "Select card from following Card";
            cardMessage.Author = new Author() { Name = "Nancy", Avatar ="Nancy.png" };
            ObservableCollection<CardButton> cardButtons = new ObservableCollection<CardButton>();
            cardButtons.Add(new CardButton() { Value = "OK", Title = "OK" });
            ObservableCollection<Card> cards = new ObservableCollection<Card>();            
    
            Card card = new Card();
            card.Title = "Audi";
            card.Subtitle = "Series";            
            card.Description = "Audi AG is a German automobile manufacturer that designs, engineers, produces, markets and distributes luxury vehicles.";            
            card.Image = "Audi.jpg"; 
    
            Card card1 = new Card();
            card1.Title = "Benz";
            card1.Subtitle = "Series";
            card1.Description = "Mercedes-Benz is a German global automobile marque and a division of Daimler AG.";
            card1.Image = "Benz.jpg";
    
            card.Buttons = cardButtons;            
            card1.Buttons = cardButtons;
    
            cards.Add(card);
            cards.Add(card1);
    
            cardMessage.Cards = cards;
            sfChat.Messages.Add(cardMessage);
    
            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:CardMessage
                        Author = "{Binding IncomingMessageAuthor, Source={x:Reference viewModel}}"
                        Cards = "{Binding cards, Source={x:Reference viewModel}}" >
                    </ sfchat:CardMessage>
                </sfchat:SfChat.Messages>
           </sfchat:SfChat>
        </ContentPage.Content>
    </ContentPage>

    Constructors

    CardMessage()

    Initializes a new instance of the CardMessage class.

    Declaration
    public CardMessage()

    Fields

    CardsProperty

    Identifies the Cards Xamarin.Forms.BindableProperty.

    Declaration
    public static readonly BindableProperty CardsProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty

    Properties

    Cards

    Gets or sets the collection of cards in a CardMessage.

    Declaration
    public IList<Card> Cards { get; set; }
    Property Value
    Type
    System.Collections.Generic.IList<Card>

    Methods

    Dispose()

    Releases the unmanaged resources used by the component and optionally releases the managed resources.

    Declaration
    public override void Dispose()
    Overrides
    MessageBase.Dispose()

    Implements

    ICardMessage
    ITextMessage
    IMessage
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved