Skip to content
Shiny .NET v4 is here with BLE Windows Support, Improved GPS, & More! Check It Out

ChatView | Properties & Commands

PropertyTypeDefaultDescription
MessagesIList<ChatMessage>nullMessage collection (supports INotifyCollectionChanged on MAUI)
ParticipantsIList<ChatParticipant>nullParticipant info for avatar/name/color lookup
IsMultiPersonboolfalseShow avatars and names for other participants
ShowAvatarsInSingleChatboolfalseForce avatars even in single-person mode
MyBubbleColorColor / string#DCF8C6Local user bubble color
MyTextColorColor / stringBlackLocal user text color
OtherBubbleColorColor / stringWhiteDefault other-user bubble color
OtherTextColorColor / stringBlackOther-user text color
PlaceholderTextstring"Type a message..."Input field placeholder
SendButtonTextstring"Send"Send button label
IsInputBarVisiblebooltrueShow/hide the input bar
ShowTypingIndicatorbooltrueEnable/disable typing notifications
TypingParticipantsIList<ChatParticipant>nullCurrently typing participants
ScrollToFirstUnreadboolfalseScroll to first unread instead of end
FirstUnreadMessageIdstring?nullID of the first unread message
UseHapticFeedbackbooltrueHaptic feedback on send (MAUI only)
MAUI (ICommand)Blazor (EventCallback)ParameterDescription
SendCommandEventCallback<string>text stringFires when user sends via Enter key or Send button
AttachImageCommandEventCallbackFires when user taps attach; implement your own image picker
LoadMoreCommandEventCallbackFires when user scrolls near top; prepend older messages
MethodReturnsDescription
ScrollToEnd(bool animate)voidScroll to the latest message
ScrollToMessage(string messageId, bool animate)voidScroll to a specific message by ID
public partial class ChatViewModel : ObservableObject
{
[ObservableProperty] ObservableCollection<ChatMessage> messages = [];
[ObservableProperty] ObservableCollection<ChatParticipant> participants = [];
[ObservableProperty] ObservableCollection<ChatParticipant> typingParticipants = [];
[ObservableProperty] bool isMultiPerson = true;
[RelayCommand]
void Send(string text)
{
Messages.Add(new ChatMessage
{
Text = text,
SenderId = "me",
IsFromMe = true,
Timestamp = DateTimeOffset.Now
});
}
[RelayCommand]
void AttachImage()
{
// Implement your own image picker, then add:
Messages.Add(new ChatMessage
{
ImageUrl = "https://example.com/photo.jpg",
SenderId = "me",
IsFromMe = true,
Timestamp = DateTimeOffset.Now
});
}
[RelayCommand]
void LoadMore()
{
// Fetch older messages from your data source and insert at index 0
var olderMessages = FetchOlderMessages();
foreach (var msg in olderMessages)
Messages.Insert(0, msg);
}
}

The Blazor <ChatView> component mirrors the MAUI control. Colors use CSS strings and commands use EventCallback:

@using Shiny.Blazor.Controls.Chat
<div style="height:600px;">
<ChatView Messages="messages"
Participants="participants"
IsMultiPerson="true"
TypingParticipants="typingParticipants"
SendCommand="OnSend"
AttachImageCommand="OnAttach"
LoadMoreCommand="OnLoadMore"
MyBubbleColor="#DCF8C6"
OtherBubbleColor="#FFFFFF" />
</div>
@code {
List<ChatMessage> messages = new();
List<ChatParticipant> participants = new();
List<ChatParticipant> typingParticipants = new();
Task OnSend(string text)
{
messages.Add(new ChatMessage
{
Text = text,
SenderId = "me",
IsFromMe = true,
Timestamp = DateTimeOffset.Now
});
StateHasChanged();
return Task.CompletedTask;
}
Task OnAttach() => Task.CompletedTask;
Task OnLoadMore() => Task.CompletedTask;
}