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 6865525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:03:47+00:00 2026-05-27T03:03:47+00:00

I have a situation: DataGrid with TemplateColumn. Template contains Stack panel with CheckBox and

  • 0

I have a situation:
DataGrid with TemplateColumn. Template contains Stack panel with CheckBox and TextBox. What I want is when I press CheckBox then TextBox which is on the same StakcPanel set value to 1.
So in simple
CheckBox -> IsChecked==true -> Set TextBox value to 1 (TextBox on the same StackPanel as CheckBox)

I try with RelativeSource but not work.
Thanks For help.

  • 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-27T03:03:48+00:00Added an answer on May 27, 2026 at 3:03 am

    Well you can bind the Content of the TextBox TextForTextBox, and bind the Checked state to Checked. in your viewModel you would : do

    private string _text;
        private bool _checked;
    
        public string TextForTextBox
        {
            get { return _text; }
            private set { _text = value;}
        }
    
        public bool Checked
        {
            get { return _checked; }
            set
            {
                if (_checked != value)
                {
                    _checked = value;
                    Text = _checked ? 1 : = 0;
                    PropertyChanged("Checked");
                    PropertyChanged("TextForTextBox");
                }
            }
        }
    

    This is assuming that you have a ViewModel that implements the INotfiyPropertyChanged.

    EDIT
    Code to change this in pure XAML :

     <Grid>
        <StackPanel>
            <CheckBox x:Name="check" />
            <TextBox>
                <TextBox.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=check, Path=IsChecked}" Value="True">
                                <Setter Property="TextBox.Text" Value="1" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ElementName=check, Path=IsChecked}" Value="False">
                                <Setter Property="TextBox.Text" Value="0" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBox.Style>
            </TextBox>
        </StackPanel>
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the situation: I have a populated datagrid and I want to move a
I have a situation where I need to work with a datagrid and adding
I have situation in which I read a record from a database. And if
We have a situation where users are allowed to upload content, and then separately
The situation is simple. I have a datagrid that gets its data from a
I have situation in which i'm compelled to retrieve 30,000 records each to 2
i have situation in which i have some library projects, say DataProcessors,Lib2 , included
I have a situation where ItemsSource property of a DataGrid is an array of
I have a Silverlight DataGrid and want to show the RowDetails of selected rows
I have a situation where I'm using a datagrid to display two different sets

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.