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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:31:39+00:00 2026-05-30T23:31:39+00:00

Im new to WPF / Silverlight so its hard for me to describe what

  • 0

Im new to WPF / Silverlight so its hard for me to describe what i try to do. Maybe that is the reason i could not find a answer on Stackoverflow and Google.

I try to bind to a DependyProperty programmatically.

public static DependencyProperty MyDependencyProperty
        = DependencyProperty.RegisterAttached(
                            "...", 
                            typeof(...),
                            typeof(...),
                            new PropertyMetadata(...)
                      );
xmlns:MyXMLNS="clr-namespace:...."

<ListBox MyXMLNS:MyClass.MyDependencyProperty="...">
    // ....
</ListBox>

This already works as expected.

How can i get this done programmatically?

  • 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-30T23:31:40+00:00Added an answer on May 30, 2026 at 11:31 pm

    The format in code is always the same and just a non-verbatim translation if you know how the XAML is handled.

    <ListBox local:Attached.Test="{Binding PathToProperty)"/>
    
    var binding = new Binding("PathToProperty");
    listBox.SetBinding(Attached.TestProperty, binding);
    

    If you set other properties on the binding like ElementName you should set those before SetBinding. (This SetBinding method is just for convenience (if you only set the Binding.Path there even is another one), for non-FrameworkElements you need BindingOperations.SetBinding)

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

Sidebar

Related Questions

I am new to the WPF. I know that silverlight is asynchronous by default.
I'm new to silverlight and wpf programming I've just created a simple storyboard in
While designing a new WPF application I noticed exceptions not being thrown during data
In my new WPF/silverlight app, is it better to directly connect to my remote
I Have a Silverlight WPF app that shows tabs of data in this case
Kinda new to Silverlight and have some experience with WPF but I'm doing a
Im starting learning Silverlight (Im decent with WPF :P). Im always try to put
I have been playing around with the WPF GridView control (DesktopUI not Silverlight) and
I am new to the WPF and Silverlight and Prism 4 , Can we
I'm new to MVVM. Currently I'm developing a WPF project in C# that will

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.