.

Working with ListViews in WPF

This will bind a datasource to a ListView and display it. It includes a event for mouse left button down

<ListView ItemsSource="{Binding Path=., Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MaxHeight="430">
    <ListView.ItemTemplate>
        <DataTemplate>
            <DockPanel LastChildFill="True">
                <TextBlock Text="{Binding FullName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
            </DockPanel>
        </DataTemplate>
    </ListView.ItemTemplate>
    <ListView.ItemContainerStyle>
        <Style TargetType="{x:Type ListBoxItem}">
            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBox_MouseLeftButtonDown" />
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

Enjoy!

What's your thoughts on this?

*

Protected by WP Anti Spam