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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:16:00+00:00 2026-05-10T20:16:00+00:00

I feel like I’m missing a fairly fundamental concept to WPF when it comes

  • 0

I feel like I’m missing a fairly fundamental concept to WPF when it comes to databinding, but I can’t seem to find the right combination of Google keywords to locate what I’m after, so maybe the SO Community can help. 🙂

I’ve got a WPF usercontrol that needs to databind to two separate objects in order to display properly. Both objects must be dynamically set from an outside source. Thus far I’ve simply been using the DataContext property of the form for dynamic object binding, but that only allows for one object to be referenced. I feel like this is a simple problem and that I must be missing something obvious.

My previous attempt looks something like this:

<UserControl.Resources>     <src:Person x:Key='personSource' />     <src:Job x:Key='jobSource' /> </UserControl.Resources> <TextBox Text='{Binding Source={StaticResource personSource}, Path=Name' /> <TextBox Text='{Binding Source={StaticResource jobSource}, Path=Address' /> 

This will bind to any defaults I give the classes just fine, but If I try to dynamically set the objects in code (as I show below) I don’t see any change.

Person personSource = FindResource('personSource') as Person; personSource = externalPerson; Job jobSource= FindResource('jobSource') as Job; jobSource = externalJob; 

What am I missing?

  • 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. 2026-05-10T20:16:00+00:00Added an answer on May 10, 2026 at 8:16 pm

    I would probably use a CustomControl with two DependencyProperties. Then the external site that uses your custom control could bind the data that they want to that control, also by using a custom control you can template the way the control looks in different situations.

    Custom control code would look something like:

    public class CustomControl : Control {     public static readonly DependencyProperty PersonProperty =         DependencyProperty.Register('Person', typeof(Person), typeof(CustomControl), new UIPropertyMetadata(null));     public Person Person     {         get { return (Person) GetValue(PersonProperty); }         set { SetValue(PersonProperty, value); }     }       public static readonly DependencyProperty JobProperty =         DependencyProperty.Register('Job', typeof(Job), typeof(CustomControl), new UIPropertyMetadata(null));     public Job Job     {         get { return (Job) GetValue(JobProperty); }         set { SetValue(JobProperty, value); }     }      static CustomControl()     {         DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl), new FrameworkPropertyMetadata(typeof(CustomControl)));     } } 

    Generic.xaml is a file that should be created for you and could have a Style that looks something like this:

    <ResourceDictionary     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     xmlns:local='clr-namespace:WpfApplication3'>       <Style TargetType='{x:Type local:CustomControl}'>         <Setter Property='Template'>             <Setter.Value>                 <ControlTemplate TargetType='{x:Type local:CustomControl}'>                     <Border Background='{TemplateBinding Background}'                             BorderBrush='{TemplateBinding BorderBrush}'                             BorderThickness='{TemplateBinding BorderThickness}'>                         <StackPanel>                             <TextBox Text='{TemplateBinding Person.Name}' />                             <TextBox Text='{TemplateBinding Job.Address}' />                         </StackPanel>                     </Border>                 </ControlTemplate>             </Setter.Value>         </Setter>     </Style> </ResourceDictionary> 

    Finally, when you go to use your control you would do something like this.

    <src:CustomControl Person='{Binding Person}' Job='{Binding Job}' /> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I use the RepositoryRecord in SubSonic which is 'mostly' poco.… May 11, 2026 at 12:15 pm
  • added an answer (edit - I think I misunderstood the original question) Simply… May 11, 2026 at 12:15 pm
  • added an answer Since PH 4.2 in_array can also use arrays as needle.… May 11, 2026 at 12:15 pm

Related Questions

I feel like I should know this, but I haven't been able to figure
I feel like I'm missing a fairly fundamental concept to WPF when it comes
I feel like I'm re-inventing the wheel here, but I need to find a
I feel like i am completely missing something because I am not able to
I feel like I am always reinventing the wheel for each application when it
I'm at a point in my development learning where I feel like I must
I feel like a fool, but here goes: public interface IHasErrorController{ ErrorController ErrorController {
I feel like this is a stupid question because it seems like common sense
I feel like developers talk about memory leaks but when you ask them what
I feel like this is a dumb question and I'm missing something, but I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.