golgepapaz
Topic Author
Posts: 43
Joined: 01 Aug 2013, 01:59

ListBox does not insert items at top

25 Sep 2013, 22:55

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.
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: ListBox does not insert items at top

27 Sep 2013, 01:49

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.
 
golgepapaz
Topic Author
Posts: 43
Joined: 01 Aug 2013, 01:59

Re: ListBox does not insert items at top

05 Jan 2014, 20:42

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?
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: ListBox does not insert items at top

07 Jan 2014, 18:22

We solved this issue in 1.1.3 version. I tested your sample and was working correctly.
Have you tried with the latest version?
 
golgepapaz
Topic Author
Posts: 43
Joined: 01 Aug 2013, 01:59

Re: ListBox does not insert items at top

08 Jan 2014, 00:36

Yup. It's fixed. Thanks.

Who is online

Users browsing this forum: No registered users and 1 guest