5

I'm trying to set a Listbox from a txt file. I read the file and populate a list, then I want to display it in the listbox, but I have no Datasource option available (only DataContext and DataContextChanged).

My Listbox is declared in XAML :

    <ListBox Name="ScriptList"  
        Grid.Row="0"
        Grid.Column="1"
        TextBlock.FontSize="12"
        Margin="2" />

Any idea why ?

Also, is it the right way to proceed (read file ->

1
  • 1
    Ok nevermind, i've used ItemsSource and it works. I tried Datasource from an example on another question here..
    – ack__
    Commented Apr 12, 2011 at 5:43

2 Answers 2

10

i've used ItemsSource and it works.

0

I was able to do this:

listbox.ItemSource = previous DataSource

listbox.DisplayMemberPath = previous ValueMember

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.