Well, I just got less that 10 items and I can see the listbox populating it, looks like crawling when it is being populated. Here is my DataTemplate:
Here's be listbox definition:
And here's how I am populating it.
Can you guys recommend on some improvements I can make? What I've noticed it, even after the ItemsSource is already set, when I click on the TabPage where the Listbox is contained and I clicked on that TabPage, I can it being populated one at a time.
Code:
<DataTemplate x:Key="exerciseTemplate">
<Border Name="border" BorderBrush="Blue" BorderThickness="1" Padding="5" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Name="col1" Width="*" />
</Grid.ColumnDefinitions>
<extToolkit:RichTextBox
Text="{Binding Path=Exercise, Mode=TwoWay}"
Focusable="False"
IsReadOnly="True"
Width="Auto"
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Stretch" >
<FlowDocument PageWidth="1000"></FlowDocument>
</extToolkit:RichTextBox>
</Grid>
</Border>
</DataTemplate>
Code:
<ListBox HorizontalContentAlignment="Stretch" ItemTemplate="{StaticResource exerciseTemplate}" Margin="6" Name="listBoxExercises" SelectionMode="Single" SnapsToDevicePixels="False" VerticalContentAlignment="Stretch" VirtualizingStackPanel.VirtualizationMode="Recycling" />
Code:
private void PopulateExercises(int topicID)
{
db.ConnectionString = Settings.ConnectionString;
OleDbCommand cmd = new OleDbCommand("SELECT * FROM Exercises WHERE TopicID=" + topicID, db);
db.Open();
OleDbDataReader reader = cmd.ExecuteReader();
exercises = new ExercisesList();
if (reader.HasRows)
{
while (reader.Read())
{
exercises.Add(new cExercise(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetValue(3).ToString(), reader.GetBoolean(4)));
}
}
reader.Close();
db.Close();
listBoxExercises.ItemsSource = exercises;
}