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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:33:10+00:00 2026-05-14T02:33:10+00:00

I’m having one hell of a time trying to get my databinding to work

  • 0

I’m having one hell of a time trying to get my databinding to work correctly. I have reason to believe that what I’m trying to accomplish can’t be done, but we’ll see what answers I get.

I’ve got a UserControl. This UserControl contains nothing more than a button. Now within the code behind, I’ve got a property name IsBookmarked. When IsBookmarked is set, code is run that animates the look of the button. The idea is that you click the button and it visually changes. We’ll call this UserControl a Bookmark control.

Now I have another control, which we’ll call the FormControl. My FormControl contains a child Bookmark control. I’ve tried to do databinding on my Bookmark control, but it’s not working. Here’s some code to help you out.

This is the XAML and Loaded event handler of my control. As you can see it contains a child element that is a custom control (bookmark). So once this control loads, it’s DataContext is set to an new instance of an Employee object. Silverlight also sets the DataContext property of my child bookmark control to the same instance. I’ve verified this by debugging. If my parent has a valid DataContext set then why can’t my child control (bookmark) property databind to it?

<UserControl ......>
    <q:Bookmark x:Name="BookMarkControl1" IsBookmarked="{Binding IsSiteBookmarked}" />
</UserControl>

public void Control_Loaded(object sender, EventArgs e)
{
    DataContext = new Employee { IsSiteBookmarked = True };

}

This is my custom control below. Obviously it contains more than this, but for readability I’ve trimmed it down to the property I’m trying to databind to.

//this is the bookmark control. I've included this control within another control, and I'm trying to databind to properties within my parents DataContext
public partial class Bookmark : UserControl
{

    bool _IsBookmarked= false;
    public bool IsBookmarked
    {
        get {return _IsBookmarked;}
        set { 
                 _IsBookmarked= value;
                 SwitchMode(value);
            }
    }

}

UPDATE

Got some javascript errors that I should mention. Firebug reports a AG_E_PARSER_BAD_PROPERTY_VALUE exception. It doesn’t seem like my databinding is even working yet.

  • 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-14T02:33:11+00:00Added an answer on May 14, 2026 at 2:33 am

    Make your IsBookmarked property on the Bookmark control a dependency property.

    I presume Control_Loaded is a part of your FormControl, in which case I’m not sure you are using DataContext properly. Best double check that.

    UPDATE: Yes, you are using the DataContext properly. AG_E_PARSER_BAD_PROPERTY_VALUE indicates you need to make the IsBookmarked property a dependency property, like so:

     Public Property IsBookmarked() As Boolean
        Get
            Return Me.GetValue(IsBookmarkedProperty)
        End Get
        Set(ByVal value As Boolean)
            Me.SetValue(IsBookmarkedProperty, value)
        End Set
    End Property
    
    Public Shared ReadOnly IsBookmarkedProperty As DependencyProperty = DependencyProperty.Register("IsBookmarked", GetType(Boolean), GetType(Bookmark), New PropertyMetadata(New PropertyChangedCallback(AddressOf OnIsBookmarkedPropertyChanged)))
    
    Private Shared Sub OnIsBookmarkedPropertyChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
        Dim cntrl As Bookmark = TryCast(d, Bookmark)
        cntrl.SetIsBookmarked(e.NewValue)
    End Sub
    

    If you only need to store the value for later use, then you don’t need to do anything in the OnIsBookmarkedPropertyChanged procedure, But I put some code there as an example anyway.

    Good Luck!

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.