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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:39:45+00:00 2026-05-15T02:39:45+00:00

to date I have created and setup bindings and dependencies between controls and other

  • 0

to date I have created and setup bindings and dependencies between controls and other objects when they are located within the same directory or within the same xaml document.

Now I have created a usercontrol which is located in a directory of my project called “Controls” this control is then loaded within the main xaml document using the tag

my question is how do I go about setting up bindings between the objects within the user control and objects within the main xaml document.

An example of this would be if I have a textbox within my user control and within the main xaml page I have a checkbox. When the checkbox is clicked I want to set the visibility of the the textbox to Collapsed.

As I said I have been able to do this when both objects are within the same document But now since the text field is placed inside a user control and within a directory I am unsure of how to reference it.

Thank you

  • 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-15T02:39:46+00:00Added an answer on May 15, 2026 at 2:39 am

    Add a DependencyProperty to your UserControl. In your main window’s XAML, bind to the DependencyProperty. In your UserControl’s XAML, bind to the same DependencyProperty using RelativeSource FindAncestor.

    For example if your UserControl is called “MyUserControl” and has a DependencyProperty “ShowDetails”, the binding in the main XAML would be:

    <Window ...>
      ...
      <local:MyUserControl ShowDetails="{Binding IsChecked,ElementName=checkBox}" />
      ...
      <CheckBox x:Name=checkBox Content="Show Details" />
      ...
    </Window>
    

    and in the UserControl’s XAML it would be:

    <UserControl ...>
      ...
      <Textbox ...
         Visibility="{Binding ShowDetails,
           RelativeSource={RelativeSource FindAncestor,local:MyUserControl,1},
           Converter={StaticResource BoolToVisibiltyConverter}" />
      ...
    </UserControl>
    

    Better yet, use the MVVM pattern. In this case you would put the DependencyProperty in your ViewModel which would be accessible throught the DataContext of both your main window and your UserControl. With MVVM there is no need to use FindAncestor or ElementName because both the CheckBox and the TextBox bind directly to the property in the ViewModel:

    <Window ...>
    
      <local:MyUserControl />
      ...
      <CheckBox IsChecked="{Binding ShowDetails}" Content="Show Details" />
    
    </Window>
    

    with this UserControl:

    <UserControl>
      ...
      <TextBox ...
         Visibility="{Binding ShowDetails,
           Converter={StaticResource BoolToVisibiltyConverter}" />
      ...
    </UserControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing reports and the date/time they were created. I'd like
I have created a CPTTradingRangePlot using the up-to-date sample code as an example. The
I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it
I have the following table <thead> <tr> <th>Account ID</th> <th>Code</th> <th>Date Created</th> <th>Date Expires</th>
So I have a database called development.sqlite3 and it is in the same directory
I have created a file called 'userhistoryreport.php'. It will be setup to run once
I have a table called 1 Main Contacts (Main), and several other tables. They
Structure of my table : ID(int) | NUMBER(int) | CREATED_AT(date) If I have three
I have a model with these 2 columns created_at: date last_updated_at: date Is it
I have to create an app in which I must set a date and

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.