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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:46:43+00:00 2026-05-11T10:46:43+00:00

I have such task – to create control that union two controls (DataGrid from

  • 0

I have such task – to create control that union two controls (DataGrid from WPFToolkit and standard Toolbar). On a large scale, it doesn’t matter what particular controls it unions, I need to find out the common practices that can be used to build what I need. At first glance, I need something like user control, i.e composition of controls, that I can implement as a whole and reuse then. But, my task requires me to have possibility to tune my composite control in XAML. So, if I compose Toolbar and DataGrid, I want properties and events of both them would be exposed. So I could set in XAML both, for example, columns of datagrid and bars of toolbar:

(I put spaces in tag names intentionally, because loacal parser didn’t type them for some reason)

<MyDataGridToolBarControl> <DataGrid>         <DataGrid.Columns>             <DataGridTextColumn Header='firstColumn'>             </DataGridTextColumn>             <DataGridTextColumn Header='secondColumn'/>         </DataGrid.Columns> </DataGrid> <ToolBar Background='{x:Null}'>          <Button ToolTip='New'>             <Image Source='New.png'/>         </Button>         <Button ToolTip='Save'>             <Image Source='Save.png'/>         </Button>         <Button ToolTip='Delete'>             <Image Source='Delete.png'/>         </Button>                </ToolBar> </MyDataGridToolBarControl> 

The only decison that suits me less or mor for now is to make custom control inherited from Datarid (as DataGrid is more significant in this pair) and redefine Template including both datagrid and toolbar. This gives me all power of datagrid but, if I want get Toolbar part, I need to do it through code, seeking it in viual and logical trees i.e. getting access o it programmatcally, which is not pretty decision. Please help a newbie to solve this task ) Thanks in advance…

  • 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-11T10:46:44+00:00Added an answer on May 11, 2026 at 10:46 am

    If it’s just a matter of wanting users on the outside to access every property of the grid and every property of the toolbar via Xaml then using composition you could create a usercontrol and expose the two controls like this:

    <UserControl>      <StackPanel>         <ToolBar x:Name='ToolBar' x:FieldModifier='Public' />         <DataGrid x:Name='Grid' x:FieldModifier='Public' />              </StackPanel>  <UserControl> 

    The problem with this approach is that that users cannot override the layout of the grid and toolbar because it is a user control. They can however completely override the templates and styles of the toolbar and the grid.

    A slightly better approach would be to create a custom control (again using composition). You could supply could the grid and the toolbar in the template like this:

    <ControlTemplate>         <StackPanel>             <ToolBar x:Name='PART_ToolBar' />             <DataGrid x:Name='PART_Grid' />                  </StackPanel> </ControlTemplate>  [TemplatePart('PART_ToolBar', typeof(ToolBar))] [TemplatePart('PART_Grid', typeof(DataGrid))] public class MyCustomControl : Control {     private ToolBar _ToolBar;     public ToolBar ToolBar {get{return _ToolBar;}}      private DataGrid _Grid;     public DataGrid Grid {get{return _Grid;}}      protected overrides OnApplyTemplate()     {          _ToolBar = this.Template.FindName('PART_ToolBar', this) as ToolBar;          _Grid = this.Template.FindName('PART_Grid', this) as DataGrid;     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • 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
  • Editorial Team
    Editorial Team added an answer We detect that the database has failed and manually failover… May 11, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer You have at least three options: Use Regex.Escape and compare… May 11, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer If you're using xUnit.net, there's an AutoRollback attribute in the… May 11, 2026 at 8:45 pm

Related Questions

I have such task - to create control that union two controls (DataGrid from
I am in need of a performance-oriented hash function implementation in C++ for a
I have been recently (and repeatedly) asked by customers about MIPS needed to run
I would like to use the result of the following filelist (Ant): <filelist id=docfiles
I have the problem that an specific step in Ant can only be executed

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.