![]() You've probably noticed that there's an unfortunate amount of XAML duplication above - each of the three HierarchicalDataTemplates are very nearly identical.Therefore, I'm able to insert the appropriate counter-offset for each level of the tree - and everything lines up beautifully! Having done that, the "Toggle" size group can be used to simulate the width of the actual toggle anywhere it's needed. So what I've done is add a special shared size group with exactly the same width as the toggle (this is what the empty TreeViewItem in the header section of the XAML is for). So if all we did was make each column's cells the same width, things wouldn't actually line up because of this offset showing up in different amounts everywhere: You see, each collection of children is offset to the right by exactly the width of the TreeViewItem's toggle element. The following diagram of the default TreeViewItem layout should help explain what I mean: The "Toggle" shared size group which is used to offset TreeViewItem children to take into account the indent that TreeViewItem parents automatically impose on them.Except that they wouldn't actually line up if it weren't for. ![]() In this manner, same-width columns are created for the "Task", "Duration", and "Notes" fields so they all line up properly. In the scenario above, that sharing takes place across the separate Grids of the column headers and each TreeViewItem row of data. (Both available only on WPF for now.) By setting IsSharedSizeScope on a parent element and SharedSizeGroup on some of the column/row definitions of Grids within it, it's possible to "link" the sizes of cells across different Grids. The first is the Grid.IsSharedSizeScope attached DependencyProperty and its partner-in-crime DefinitionBase.SharedSizeGroup.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |