How can I bind a LinkedList as ItemSource to ListView in WPF XAML?

Posted by Jonas on Stack Overflow See other posts from Stack Overflow or by Jonas
Published on 2010-06-14T18:01:41Z Indexed on 2010/06/14 18:12 UTC
Read the original article Hit count: 196

Filed under:
|
|
|
|

I'm learning WPF and would like to have a collection similar to a LinkedList, to where I can add and remove strings. And I want to have a ListView that listen to that collection with databinding. How can I do bind a simple list collection to a ListView in XAML?

My idea (not working) is something like this:

<Window ...>
    <Window.Resources>
        <LinkedList x:Key="myList"></LinkedList>
    <Window.Resources>
    <Grid>
    <ListView Height="100" HorizontalAlignment="Left" Margin="88,134,0,0" 
    Name="listView1" VerticalAlignment="Top" Width="120" 
    ItemsSource="{Binding Source={StaticResource myList}}"/>
    </Grid>
</Window>

© Stack Overflow or respective owner

Related posts about wpf

Related posts about databinding