Ok this has been asked many times but I just can't find the right solution. I have datagrid defined like this:
<DataGrid AutoGenerateColumns="False"
IsReadOnly="True"
Name="InputDocItemsDataGrid"
ItemsSource="{Binding Path= InputItems}"
SelectedItem="{Binding Path= InputItem, UpdateSourceTrigger=PropertyChanged}"
SelectionChanged="InputDocItemsDataGrid_SelectionChanged"
PreviewMouseLeftButtonDown="InputDocItemsDataGrid_PreviewMouseLeftButtonDown">
<DataGrid.Columns>
<DataGridTemplateColumn CanUserReorder="False" CanUserResize="False">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<CheckBox Name="cbxAll" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" Checked="cbxAll_Checked" />
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox Name="cbxSingleRow" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" PreviewMouseLeftButtonDown="cbxSingleRow_PreviewMouseLeftButtonDown" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Well I added only this template column here becouse it's the point of interest. So what I'm trying to manage is to access checkobx "cbxSingleRow" as it is outside of datagrid, so i would be able to do all the regular stuff with it like for example: cbxSingleRow.IsEnabled = false;
So how do I get that checkbox?
I just need to access that checkbox from codebehind- what for? whatever you want to do, do it via DataBinding.