Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6707669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:40:02+00:00 2026-05-26T07:40:02+00:00

I have TWO custom controls. First I have an checkbox custom control, myCheckboxControl, (simplied

  • 0

I have TWO custom controls. First I have an checkbox custom control, myCheckboxControl, (simplied xaml below)

<UserControl x:Class="UserControls.myCheckboxControl"><Grid>
        <CheckBox x:Name="chkboxList" HorizontalAlignment="Center" Checked="chkboxList_Checked">
</Grid></UserControl>

I also have a a custom DataGrid control (simplified xaml below) that contains the checkbox control in a DataTemplate

<UserControlx:Class="UserControls.myDataGridControl"><DataGrid x:Name="dgMyGrid>
<DataGrid.Columns>
          <DataGridTemplateColumn x:Name="tempCol" Header="Checkbox(L)">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <localControls:myCheckboxControl x:Name="controlList"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>

Then I have the DataGrid (myDataGridControl) in my MainWindow.

The question I have is that I have a Button on the MainWindow. When that Button is Clicked, I need it to also check the checkbox within myCheckboxControl. I can get the SelectedItem of the datagrid, but just not sure how to get my 2 level deep checkbox to get checked.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:40:02+00:00Added an answer on May 26, 2026 at 7:40 am

    As you have already known that the checkbox is a descendent of a user control which is hosted on a datagrid row.

    So you will have to resolve these 2 level boundaries by using a mediator property at myCheckboxControl to hold CheckBox.IsChecked. You can introduce a new dependency property in myCheckboxControl say IsCheckBoxChecked an use that in further discussion.

    I am using another property called Tag which is a placeholder for any extra information one may want to add against a framework element.

        <UserControl x:Class="UserControls.myCheckboxControl">
            <Grid>
                <CheckBox x:Name="chkboxList"
                          HorizontalAlignment="Center"
                          IsChecked="{Binding
                                        Tag,
                                        RelativeSource={RelativeSource
                                            AncestorType={x:Type UserControl}}
                                        Mode=TwoWay}">
           </Grid>
       </UserControl>
    
    
       <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
                <localControls:myCheckboxControl
                           Tag="{Binding
                                    IsSelected,
                                    Mode=TwoWay,
                                    RelativeSource={RelativeSource
                                       AncestorType={x:Type DataGridRow}}}"
                           x:Name="controlList"/>
            </DataTemplate>
       </DataGridTemplateColumn.CellTemplate>  
    

    Thus when you programmatically select datagrid row(s) then corresponding checkbox on that row will get checked. Also when you check the checkbox the row will get selected and vice versa.

    Now if you dont want selection to take place upon checking the checkbox, you will have to introduce a INotifyPropertyChanged based notifiable property at row item level.

    E.g. if you are binding a list of employees to the datagrid then each employee class must have a settable property called “IsSelected”. This class must implement INotifyPropertyChanged interface and should raise a property changed notification from setter that IsSelected property.

    In such case the binding is changed to this…

                <localControls:myCheckboxControl
                           Tag="{Binding
                                    IsSelected,
                                    Mode=TwoWay}"
                           x:Name="controlList"/>
    

    Let me know if this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two custom controls that are analogous to a node and the control
I have two simple custom controls derived from standard WPF controls. I.e. internal class
I do have two problems regarding custom controls: I created a custom UserControl public
I have a control which extends UserControl . This control contains two ComboBox controls.
I have two ItemsControls, one a ListView, and one a custom control I am
I have a Silverlight custom control with two properties; Text and Id. I have
I have two custom ActionFilters on an action. In first of the actionfilters, I
I have a IEnumerable. I have a custom Interval class which just has two
Let's say you have two classes that extend UserControl . Each of the controls
Is there a way to pop a usercontrol/control let say a Grid,ViewBox or custom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.