0

i have a multicolumn ListBox as you can see below.

<ListBox x:Name="lstQuestions" HorizontalAlignment="Left" Height="544" VerticalAlignment="Top" Width="175" Margin="0,0,0,-0.5" SelectionChanged="lstQuestions_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="0,2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="20"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="{Binding qID}"/>
                                <Image Source="{Binding imgPath}" Width="140" Height="50" Stretch="UniformToFill" Grid.Column="1"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

I want to show the index number (like 1, 2, 3 ...) instead of <TextBlock Text="{Binding qID}"/> in first column, how can I do that?

Edit: Binding code behind

 public class QList
{
    public string qID { get; set; }
    public string imgPath { get; set; }
    public int ansCount { get; set; }
    public string rightAns { get; set; }
}

and

public static List<QList> questions = new List<QList>();

last one

lstQuestions.ItemsSource = Test.questions;

The first two are in a class called Test

cameloper
  • 297
  • 1
  • 3
  • 16

0 Answers0