-
- golgepapaz
- Posts: 43
- Joined:
ListBox does not insert items at top
While writing a simple log viewer in unity, I am trying to insert items at top but control insists on adding it to the bottom of the list .
Sample XAML and Script
Please tell me I am not using the control wrong.
Sample XAML and Script
Code: Select all
<StackPanel x:Name="LogViewerPanel" VerticalAlignment="Bottom" HorizontalAlignment="Center" Opacity="0.495">
<Expander Header="Log Window" ExpandDirection="Up" Width="400">
<ListBox x:Name="LogViewerListBox" Width="Auto" MinHeight="200" MaxHeight="200" MinWidth="400" />
</Expander>
</StackPanel>
Code: Select all
public void LogMessage(string message)
{
ListBox logger = guiRoot.FindName<ListBox>("LogViewerListBox");
var item = new TextBlock(message);
item.SetOpacity(1f);
Brush brush = new SolidColorBrush(Noesis.Color.Yellow);
item.SetForeground(brush);
logger.GetItems().Insert(0, item);
}
-
-
sfernandez
Site Admin
- Posts: 3238
- Joined:
Re: ListBox does not insert items at top
There is a bug with the insertion of collection items into the visual items host, they are always added at the end of the list, thanks for reporting. We will try to solve it as soon as possible.
Meanwhile you can maintain an ordered list of messages, and every time a new message is generated, recreate the collection of items:
Sorry for the inconvenience.
Meanwhile you can maintain an ordered list of messages, and every time a new message is generated, recreate the collection of items:
Code: Select all
public void LogMessage(string message)
{
TextBlock item = new TextBlock(message);
item.SetOpacity(1f);
item.SetForeground(Brushes.Yellow());
this._messageList.Insert(0, item);
ItemCollection items = this._logger.GetItems();
items.Clear();
foreach (TextBlock tb in this._messageList)
{
items.Add(tb);
}
}
-
- golgepapaz
- Posts: 43
- Joined:
Re: ListBox does not insert items at top
I see that this issue is not resolved yet. Do you have an internal ticket for this? if not would you like me to create one?
-
-
sfernandez
Site Admin
- Posts: 3238
- Joined:
Re: ListBox does not insert items at top
We solved this issue in 1.1.3 version. I tested your sample and was working correctly.
Have you tried with the latest version?
Have you tried with the latest version?
Who is online
Users browsing this forum: Ahrefs [Bot], tuwi and 46 guests