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

  • Home
  • SEARCH
  • 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 6004259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:14:18+00:00 2026-05-23T01:14:18+00:00

I am developing a custom WPF control and confused how to use the dependency

  • 0

I am developing a custom WPF control and confused how to use the dependency property. My view model contains 2 properties:

class Customer {
  string Name;
  string ID;
}

My custom control is responsible for displaying these fields.

Q1: Do I need to define any dependency properties (eg “Name”, “ID”) in my custom control?

Q2: I am using ItemsControl to display a list of Customers. How is the Customer object passed to my custom control? Is it done through the DataContext or do I need to add a “Customer” dependency property in my control and in the xaml, bind “Customer” to “something” (what’s that something)?

<ItemPresenter>
   <MyCustomControl  Customer="??what should i put here???"/>
</ItemPresender>
  • 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-23T01:14:18+00:00Added an answer on May 23, 2026 at 1:14 am

    Q1. Why do you have a custom control? Ordinarily, you would just create a UserControl (there is a distinction in WPF between UserControl and custom control) and bind properties within your UserControl to properties of your view model. For example (let’s call this CustomerView):

    <UserControl ...>
        <StackPanel>
            <TextBlock Text="{Binding ID}"/>
            <TextBox Text="{Binding Name}"/>
        </StackPanel>
    </UserControl>
    

    Q2. Through the DataContext. For example, you might have something like this:

    <ItemsControl ItemsSource="{Binding Customers}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <local:CustomerView/>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
    

    Each item generated by the ItemsControl will have the related data item set as its DataContext. Hence, each CustomerView will have the appropriate Customer as its DataContext.

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

Sidebar

Related Questions

I am developing a custom control derived from System.Windows.Controls.ContentControl. In the controls default template
I'm developing a custom server control in Asp.NET (.NET 3.5) which inherits the CompositeControl
Does anyone have any good links for developing custom field and content types that
H guys. I'm developing a custom component for SSIS. I'm having a problem when
Is it necessary or advantageous to write custom connection pooling code when developing applications
I'm developing a client/server app that will communicate via rest. Some custom request data
I am developing an application for PocketPC. When the application starts the custom function
I have a WPF Browser Application consisting mostly of wpf pages which I'm developing
I am developing custom iPad applications for clients. So far I know that you
I am currently working on developing custom dialog box to be used with my

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.