How to add text display to ListBox #5548
Unanswered
1746625968
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
XAML:
--
Code:
public void AddLogs(string log, LinearGradientBrush level)
{
TextBlock textBlock = new TextBlock
{
Text = DateTime.Now.ToLongTimeString() + ":" + log,
Background = level
};
textBlock.Background = level;
//textBlock.SetBinding(TextBlock.MaxWidthProperty, new Binding("ActualWidth") { Source = this });
textBlock.TextWrapping = TextWrapping.Wrap;
this.list_Log.add(textBlock);
this.list_Log.SelectedIndex = this.list_Log.Items.Count - 1;
this.list_Log.ScrollIntoView(this.list_Log.SelectedItem);
if (list_Log.Items.Count > 50)
{
list_Log.Items.RemoveAt(0);
}
}
Beta Was this translation helpful? Give feedback.
All reactions