Highlighted
Absent Member.
Absent Member.
5842 views

Wpf Listview Multi Select w/checkbox

Would like to build Listview(listbox) containing a checkbox with the ability to select as many checkbox's desired, and then update DB (codebehind) with data from the screen. I'll just read thru Listview and update. 

Example. On the screen user would enter a valid Sku# in a textbox, the user would see a Listview containing a listview of valid products, user would select (checkbox) as many rows desired and then click an update button. Behind code would read thru the listview and anything checked I would update DB.

I am unsure how to setup Listview currectly with checkbox and multi select Wondering if anynody has a working example of a WPF solution that has either Listview/Listbox with checkbox option with multi select. I know this is a very specific requerst, feel free to send me an email. Thanks

Thanks

Marc Hinrichen

mhinrichsen@lmc.net

0 Likes
4 Replies
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: Wpf Listview Multi Select w/checkbox

Hi

I would like to ask you where the problem is. Is it to define the Listview with XAML, or is it the handling of the of the Ceckbox Status in the Listview Items?

Freundliche Grüsse

Werner Lanter

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Wpf Listview Multi Select w/checkbox

My Listview layout (below) is what I have defined. Not sure if I need relativesource stmnt, but was in the example I found. I guess my question now is when I read thru the Listview in behind code, how do I determine if the checkbox was 'Checked'? Not sure what proprty value to go after.

I will read thru the Listview row by row, and if the row was checked, I will perform an update, otherwise move onto the next row.

<ListView.View>

               <GridView>

                   <GridViewColumn Header="Ven#" Width="50"

                                       DisplayMemberBinding="{Binding Path=Vs_Vnd}"></GridViewColumn>

                   <GridViewColumn Header="Name" Width="150"

                                       DisplayMemberBinding="{Binding Path=AP_Name}"></GridViewColumn>

                   <GridViewColumn Header="Sku #" Width="170" TextBlock.TextAlignment="Center"

                                       DisplayMemberBinding="{Binding Path=Vs_Sku}"></GridViewColumn>

                   <GridViewColumn Header="Whse" Width="40"

                                       DisplayMemberBinding="{Binding Path=Vs_Pc_W}"></GridViewColumn>

                   <GridViewColumn Header="Direct" Width="40"

                                       DisplayMemberBinding="{Binding Path=Vs_Pc_D}"></GridViewColumn>

                   <GridViewColumn Header="Lumber" Width="40"

                                       DisplayMemberBinding="{Binding Path=Vs_Pc_Lbr}"></GridViewColumn>

                   <GridViewColumn Header="Panels" Width="40"

                                       DisplayMemberBinding="{Binding Path=Vs_Pc_Ply}"></GridViewColumn>

                   <GridViewColumn Header="?" Width="40">

                       <GridViewColumn.CellTemplate>

                           <DataTemplate>

                               <StackPanel>

                                   <!--<CheckBox IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource Self},Mode=TwoWay}"/>-->

                                   <CheckBox Name="chk1" IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"/>

                               </StackPanel>

                           </DataTemplate>

                       </GridViewColumn.CellTemplate>                    

                   </GridViewColumn>

                   <GridViewColumn Header="Vendor Product Description" Width="520"

                                       DisplayMemberBinding="{Binding Path=Vs_Desc}"></GridViewColumn>

                   <GridViewColumn Header="# Times Rcv" Width="50"

                                       DisplayMemberBinding="{Binding Path=Vs_Edm_Count}"></GridViewColumn>

               </GridView>

           </ListView.View>

       </ListView>

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: Wpf Listview Multi Select w/checkbox

Did you receive my solution and could you find what you need?

Regards

Werner Lanter

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: Wpf Listview Multi Select w/checkbox

Attachement

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.