Xamarin.Forms

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ImageMessage

    Show / Hide Table of Contents

    Class ImageMessage

    Represents a class which specifies an image type message in SfChat.

    Inheritance
    System.Object
    MessageBase
    TextMessage
    ImageMessage
    Implements
    IImageMessage
    ITextMessage
    IMessage
    Inherited Members
    TextMessage.TextProperty
    TextMessage.Text
    MessageBase.AuthorProperty
    MessageBase.DateTimeProperty
    MessageBase.DataProperty
    MessageBase.SuggestionsProperty
    MessageBase.HideAfterSelectionProperty
    MessageBase.Dispose()
    MessageBase.Author
    MessageBase.DateTime
    MessageBase.Data
    MessageBase.Suggestions
    MessageBase.IsSuggestionViewHiddenAfterSelection
    MessageBase.IsMessageContentHiddenAfterSelection
    MessageBase.HideAfterSelection
    Namespace: Syncfusion.XForms.Chat
    Assembly: Syncfusion.SfChat.XForms.dll
    Syntax
    public class ImageMessage : TextMessage, IImageMessage, 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 { public SfChatDemo() { SfChat sfChat = new SfChat(); Author currentUser = new Author() { Name = "Nancy", Avatar = "People_Circle16.png" }; sfChat.CurrentUser = currentUser; ImageMessage message = new ImageMessage() { Aspect = Xamarin.Forms.Aspect.AspectFit, Source = "Image3.jpg", Author = currentUser, };

            ImageMessage message1 = new ImageMessage()
            {
                Aspect = Xamarin.Forms.Aspect.Fill,
                Source = "Image3.jpg",
                Author = new Author() { Name = "Andrea", Avatar = "People_Circle2.png" },
            };
    
            sfChat.Messages.Add(message);
            sfChat.Messages.Add(message1);
            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" 
                          CurrentUser="{Binding CurrentUser}">
                <sfchat:SfChat.Messages>
    
                    <sfchat:SfChat.Messages>
                        <sfchat:ImageMessage
                            Size = "{Binding Size,Source={x:Reference viewModel}}"
                            Author="{Binding Author,Source={x:Reference viewModel}}"
                            Source="{Binding ImageSource,Source={x:Reference viewModel}}">
                        </sfchat:ImageMessage>
    
                        <sfchat:ImageMessage
                            Size = "{Binding Size}"
                            Author="{Binding CurrentUser,Source={x:Reference viewModel}}"
                            Source="{Binding ImageSource,Source={x:Reference viewModel}}">
                        </sfchat:ImageMessage>
                    </sfchat:SfChat.Messages>
    
                </sfchat:SfChat.Messages>
            </sfchat:SfChat>
        </ContentPage.Content>
    </ContentPage>

    Constructors

    ImageMessage()

    Initializes a new instance of the ImageMessage class.

    Declaration
    public ImageMessage()

    Fields

    AspectProperty

    Identifies the Aspect Xamarin.Forms.BindableProperty.

    Declaration
    public static readonly BindableProperty AspectProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SizeProperty

    Identifies the Size Xamarin.Forms.BindableProperty.

    Declaration
    public static readonly BindableProperty SizeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SourceProperty

    Identifies the Source Xamarin.Forms.BindableProperty.

    Declaration
    public static readonly BindableProperty SourceProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    Properties

    Aspect

    Gets or sets the scaling mode of an image.

    Declaration
    public Aspect Aspect { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Aspect

    Size

    Gets or sets the size of an image message.

    Declaration
    public Size Size { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Size
    Remarks

    The maximum width of an image message is restricted to 80% of the chat control's width to ensure consistent UI among messages.

    Source

    Gets or sets the source of an image.

    Declaration
    public ImageSource Source { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.ImageSource

    Implements

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