0

I have this WPF ListView:

<ListView x:Name="OracleListView">
    <ListView.View>
        <GridView>
            <GridView.Columns>
                <GridViewColumn Header="Selected">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox Checked="Item_Checked" Unchecked="Item_Unchecked"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Header="Name" />
            </GridView.Columns>
        </GridView>
    </ListView.View>
</ListView>

I fill it like that:

OracleListView.Items.Add(new ListBoxItem{Content="Table A"});
OracleListView.Items.Add(new ListBoxItem{Content="Table B"});
OracleListView.Items.Add(new ListBoxItem{Content="Table C"});

So I have listview with 3 checkboxes and 3 strings. The question is:

How could I access checkbox column corresponding to selected item?

1 Answer 1

1

You can easily access the corresponding checkbox in the cheked event handler that you have already defined :

private void Item_Checked(object sender, RoutedEventArgs e)
{
    var checkBox = e.Source as CheckBox;    
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.