Hey all!

I'm working on a project at the moment that uses WPF with C#. It has 4 tab pages (view, add, edit, delete records). On the view tab page, there is a listview that displays the database (SQL using linq-to-sql) records from a particular table (lets call it 'customers'). I can select a record to edit/delete from this listview.

On the add tab page, i can add a new item (customers), as well as add related items (orders, for example) for this customer. There is a list view for the orders, that displays basic info about it. I can add a new order to the new customer record and these display in the listview. I can also select an order from the listview to edit or delete if needs be. The problem is that the listview won't let me select an item.

When i select an item, it highlights for a second and then reverts to its normal, unselected state. The info for both listviews are similar (i.e. listview1.ItemsSource = query; listview2.ItemsSource = query; and query is a sql query to get records from the database.)

// sample of the xaml listview code (the code for both listviews is the same except,m obviously, for the DisplayMemberPath and SelectedValuePath):

<ListView x:Name="ListViewDocket" Margin="24.021,164.89,21.021,57" DisplayMemberPath="CASNum" ItemsSource="{Binding}" SelectedValuePath="CASNum" SelectionMode="Single" SelectedIndex="-1">
                <GridViewColumn DisplayMemberBinding=
                      "{Binding Path=CASNum}" 
                       Header="CAS Number" Width="auto"/>

                        <GridViewColumn DisplayMemberBinding=
                         "{Binding Path=Desc}" 
                             Header="Description" Width="auto"/>

Any idea's why its not allwoing me to select an item from one listview but it is from the other and how I can fix this issue?


Figured out the problem - my own stupidity. I was refilling the list views on focus of the tab control so each time i selected a record in the listview, it would refill the listview and thus deselect my selection.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.