1

I have a ListView in a WPF Application that use Dynamic Binding. I wish to insert in the cell of a row a CheckBox instead than showing a boolean value for a specific row. It should apply to all the rows and should offcourse enable me to unset and set it (it will update the object it in the code) but i can do that last part myself. I just need to figure out how to put a checkbox there.

It is possible ? Any ideas ?

Here my XAML:

<ListView Margin="385,91,12,120"
                 Name="lstTransactions">
            <ListView.View>
                <GridView>
                    <GridViewColumn DisplayMemberBinding="{Binding Description}"
                                    Width="220">Description</GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=MontantEstimation, StringFormat='{}{0:C}'}"
                                    Width="100">Estimation</GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=MontantReel, StringFormat='{}{0:C}'}"
                                    Width="100">Réel</GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding Compte}"
                                    Width="120">Compte</GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding EstVerifie}"
                                    Width="70">Verifié ?</GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>

Thanks.

Rushino
  • 9,415
  • 16
  • 53
  • 93
  • Yes, here ive updated my question with the XAML markup. The column i want to generated a checkbox is the last one which is "Verifié ?" in english that mean "Verified ?" normally that show a true and false but i would prefer to show a checkbox instead. – Rushino Jul 21 '11 at 15:19
  • I created [this post](http://wpfexperiments.blogspot.com/2012/08/how-to-get-selected-checkboxes-in.html) explaining how I implemented multiple checkbox selection through code-behind in nested ListViews just in case anyone needs something like that.. – Adolfo Perez Sep 04 '12 at 17:40

1 Answers1

5

You gotta change the GridViewColumn.CellTemplate.
Check out the code snippet in this question
WPF: Checkbox in a ListView/Gridview--How to Get ListItem in Checked/Unchecked Event?

Community
  • 1
  • 1
Amr
  • 1,935
  • 2
  • 19
  • 29
  • I don't think that related to the rows. I think GridviewColumn are only related to the column. Actually what i want to do is change the way this value is presented in the row. (which is using a checkbox) – Rushino Jul 21 '11 at 15:29
  • I think GridViewColumn.CellTemplate will change the template of the cells that belong to this column from a textbox template to a checkbox template. Read the code snippet in the question I linked to and see if it helps. – Amr Jul 21 '11 at 15:36
  • Oh i see. It looked like something i had already tried but i was wrong. I haven't tried to use . Thanks it worked like a charm. – Rushino Jul 21 '11 at 15:43
  • Is there a way to get the row in the event handler ? – Rushino Jul 21 '11 at 15:49
  • 1
    Check the answer here, maybe it'll help http://social.msdn.microsoft.com/Forums/en/wpf/thread/66b461fc-f64c-4435-8f07-d300e53e5861 – Amr Jul 21 '11 at 15:57
  • Thanks a lots! You helped me a lots. – Rushino Jul 21 '11 at 17:12