Page 1 of 1

ListBox does not insert items at top

Posted: 25 Sep 2013, 22:55
by golgepapaz
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
	<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> 
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);
    }
Please tell me I am not using the control wrong.

Re: ListBox does not insert items at top

Posted: 27 Sep 2013, 01:49
by sfernandez
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:
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);
    }
}
Sorry for the inconvenience.

Re: ListBox does not insert items at top

Posted: 05 Jan 2014, 20:42
by golgepapaz
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?

Re: ListBox does not insert items at top

Posted: 07 Jan 2014, 18:22
by sfernandez
We solved this issue in 1.1.3 version. I tested your sample and was working correctly.
Have you tried with the latest version?

Re: ListBox does not insert items at top

Posted: 08 Jan 2014, 00:36
by golgepapaz
Yup. It's fixed. Thanks.