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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:21:23+00:00 2026-05-26T16:21:23+00:00

I have a problem with a DependencyProperty in a UserControl. My control exposes two

  • 0

I have a problem with a DependencyProperty in a UserControl. My control exposes two Dependencyproperties, a bool and a string. The string property works, but the bool doesn’t. I get no errors, but changes aren’t reflected either way.

I define the property like this:

private static readonly DependencyProperty IncludeSubdirectoriesProperty =
    DependencyProperty.Register(
        "IncludeSubdirectories",
        typeof(bool),
        typeof(DirectorySelect),
        new FrameworkPropertyMetadata(false) { BindsTwoWayByDefault = true }
        );

public bool IncludeSubdirectories
{
    get { return (bool) GetValue(IncludeSubdirectoriesProperty); }
    set { SetValue(IncludeSubdirectoriesProperty, value); }
}

In the XAML for the user control i bind to the property like this:

<CheckBox
    Name="IncludeSubdirectoriesCheckbox"
    IsChecked="{Binding Path=IncludeSubdirectories, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
    Include subfolders</CheckBox>

And when i use the control i bind to the properties like this:

<Controls:DirectorySelect
    Directory="{Binding Directory}"
    IncludeSubdirectories="{Binding WatchSubDirs}"/>

“Directory” is the string property that works just fine. I bind to them both in the same way, but i just can’t make the bool work.

Where did i go wrong?

  • 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-26T16:21:24+00:00Added an answer on May 26, 2026 at 4:21 pm

    You could try chaning the binding with your user control to an element binding. Before you do be sure to give your userControl a name.

    Then change:

         IsChecked="{Binding Path=IncludeSubdirectories, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
    

    To something like this:

         IsChecked="{Binding Path=IncludeSubdirectories, ElementName="<UserControlName>", Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
    

    Another sanity check you can perform is to make sure the type owner for IncludeSubdirectoriesProperty’ is correct.

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

Sidebar

Related Questions

I have a rather simple problem, but I am unable to get my head
I have user control with property public double X { get { return Canvas.GetLeft(this)
I have essentially the same problem discussed here: http://khason.net/blog/dependency-property-getters-and-setters-in-multithreaded-environment/ public static readonly DependencyProperty MyPropertyProperty
I have implemented my own usercontrol based on listboxes. It has a dependency property
I have a user control that has a grid (the one you get automatically
Say I have a control that inherits from UserControl (hence one of its super
I've made a simple project to illustrate my problem. I have a user control
I have one problem. i have dep. prop. of type List.. public const string
Im new to MVVM and have small problem. I have two user controls: parent
I have an Id dependency property declared: public long Id { get { return

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.