ListBox does not insert items at top
Posted: 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
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);
}