Here's a video of what's going on when I call StackLayout.Items.Add(Label)
: https://streamable.com/hczt8
It seems that the list is entirely being emptied to a new list, and the simple code is that one :
public class ChatPanel : Scrollable
{
StackLayout _messages;
public ChatPanel()
{
_messages = new StackLayout();
Content = _messages;
BackgroundColor = Colors.Azure;
_currentAccountData.Chat.EvOnChatMessage += OnMessage; // Custom event when a message is received
}
void OnMessage(ChatMessage m)
{
Label label = new Label();
string date = $"[00:00:00]";
if (m.GetType().Equals(typeof(PlayerMessage)))
{
PlayerMessage message = (PlayerMessage) m;
label.Text = $"{date} {message.Pseudo}: {message.Message}";
}
else
{
label.Text = $"{date} {((ServerMessage)m).Message}";
}
_messages.Items.Add(new StackLayoutItem(label)); // I tried without "StackLayoutItem" too
}
}
I can't find any Container or Control fitting my needs. (complete list here)
Why does it refresh like that ? Is there another Control I can use to avoid this? Or am I misusing the component ?
Label is not adapted to this.
I used RichtextBox
and set Rtf
property.
I had to make use of this answer