Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can i remove the event handler from a template column in a datagrid

My XAML:

XML
<DataGrid x:Name="dg" AutoGenerateColumns="False" Margin="10,0,0,0">
                <DataGrid.Columns>
<DataGridTemplateColumn Header="Arrived">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox x:Name="Arrived_chk" IsChecked="{Binding Path=Arrive}" Checked="Arrived_chk_Checked" Unchecked="Arrived_chk_Unchecked" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>



I have tried getting access to the control like so:

Dim chkbox As CheckBox = GetTemplateChild("Arrived_chk")

but this returns a null.

I need access to the control to remove the event handler while a certain sub takes place.

Thanks


UPDATE:

Still struggling with this I have tried using this:

dg.RemoveHandler(CheckBox.Checked, AddressOf Arrived_chk_Checked)

but still having no luck.
Posted
Updated 24-Feb-15 4:34am
v2
Comments
/\jmot 24-Feb-15 11:03am    
What about the unchecked event??
dg.RemoveHandler(CheckBox.Checked, AddressOf Arrived_chk_Checked);
dg.RemoveHandler(CheckBox.UnChecked, AddressOf Arrived_chk_UnChecked);

1 solution

Solved by using the click event instead of check and uncheck event. CLick event only fires if the user actually presses the checkbox instead of firing when the data is loaded.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900