0

It's my xaml:

<Custom:DataGridTemplateColumn Header="Pilih" Width="50" IsReadOnly="False">
                    <Custom:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox Height="23" Name="ckPilih" Checked="ckPilih_Checked">
                            </CheckBox>
                        </DataTemplate>
                    </Custom:DataGridTemplateColumn.CellTemplate>
                </Custom:DataGridTemplateColumn>

when i want to use it(ckPilih) in .cs it can't access

2 Answers 2

1

You won't have direct access to this checkbox in code behind because the scope of ckPilih is only inside the DataTemplate

On the side note, I am not sure about your use case but it is not usually recommended to access the checkbox or any other control inside DataTemplate in this manner. You should always try to bind the DataGrid with your datasource. DataGrid will then automatically reflect the changes in DataSource

Sign up to request clarification or add additional context in comments.

Comments

0

It is DataTemplate element. you can access it only in your DataTemplate definition. Instead of this, you should use DataGrid.Rows[i].Cell[j].Children property to access collection of controls in a cell.

4 Comments

there is not dataGrid.Rows in WPF, am i missing something?
may be. but i'm sure you know the way to access (i,j) cell :)
i have searched but i didn't get it, Anybody can help me?
may be Items is the answer for your question? use msdn to read more about it!

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.