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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:03:53+00:00 2026-05-26T18:03:53+00:00

I’ve written a custom panel which displays its children docked either vertically or horizontally,

  • 0

I’ve written a custom panel which displays its children docked either vertically or horizontally, separated by moving splitters in between. Since the Grid panel offers much of this functionality out-of-the-box, I just inherited from it.

To create the layout, upon Loaded is fired I do the following:

1) Read how many children it has and create the appropiate number of rows/colums.
2) Position every existing children in the corresponding row/colum.
3) Create, position and add a GridSplitter for every child.

This approach looks and works fine, but it opens the door to a lot of problems:

  • Since it’s added a GridSplitter for each child, there are twice the number of expected children. If someone added 3 elements to it, Children.Count would return 6.

  • User could insert/remove things at the wrong place.

  • It just throws an exception when this Grid is used as the ItemsPanel for an ItemsControl, since in this case WPF (not Silverlight) does not allow direct children manipulation.

These 3 cases are the ones I’ve already tested, but I’m pretty sure a lot more would arise depending on what the user does with it.

As it turns out, this class must be regarded as ‘implementation details’, so the real question is, what control should I put in front of the user?

It sounds like it should be a Panel, but I can’t control the Children property since it’s not virtual, and there’s also the ItemsControl which I think could be a good candidate, but I really don’t know.

I’d much appreciate any kind of advice or some directions to do this the right way.

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. Editorial Team
    Editorial Team
    2026-05-26T18:03:54+00:00Added an answer on May 26, 2026 at 6:03 pm

    You see using just grid you leave yourself with an imperative way of adding items only. As in
    myCustomGrid1.AddMyItem(***), Grids simply don’t have ItemsSource property. ItemsControls do – so if you need support for declarative items sources i.e. myControl.ItemsSource = {Binding …} you’re going to derive your control from ItemsControl. This is not a two liner – making your ItemsPanel Children writable is a big challange – there’s no simple way of doing that.

    This is all about a small thing overlooked during the Grid’s design – splitters shouldn’t have been added to Children collection, as Children are visulaizations of your BOs while spliiters are just formatting elements.

    Here’s what I would do.

    1. Forget about ItemsSource & items altogether – it’s aint worht the hassle. The only way to add/remove items to your control will be AddResiazableItem/RemoveResizbleItem. Calls will add items and splitter (for the middle items), extend the number of rows/cols of your grid depeneding on its orientation, set Grid.Row/Grid.Column attached properties for your visual children. You can keep your actual objects internally to support Orientation change.

    2. If at any stage you’ll want to bind your control to IEnumerable source – just create an attached behavior, which will iterate through the items and call AddResiazableItem within a loop.

    Cheers.

    P.S. To moderators – the editor seems to get broken, lads. I cant see the second item.
    P.S.S. Got it fixed after a few tries.

    • 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 am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I would like to run a str_replace or preg_replace which looks for certain words
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
I want to count how many characters a certain string has in PHP, but

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.