Also notice that the ItemsPresenter (the place holder for all the children of a TreeViewItem) is set to row 1 and column 1 & 2 (Grid.Column=”1″ Grid.ColumnSpan=”2″). Now notice that the Border that encapsulates the ContentPresenter (the place holder for where your values will live) is set to live in column 1 (remember 0 based index rules apply here). Things to note here is that the layout is controlled with a 3×2 Grid. Lets take a look at a part of the Control Template for a TreeViewItem to find the problem: I have removed a lot of content that is not relevant to what our problems is. A ControlTemplate is a layout that is composed of other primitive controls such as Button, Selector, Grid etc. Its visual representation is composed in XAML by constructing a ControlTemplate and assigning it to the Control’s Template property. For some quick background, a control is just a DependencyObject made up of C# (or any other. If you explore the problem a little bit deeper you will find that the actual problem here is the way the Template for TreeViewItem controls has been defined in the two most popular themes (Luna for XP and Aero for Vista). However these “hacks” don’t address the underlying problem (hence why I am labelling them hacks). There are various hacks to get around it that have been suggested in the community: You would think that like any other scenario in WPF you would set either the HorizontalAlignment on the TreeViewItem or the HorizontalContentAlignment on a parent entity like the TreeView itself. It is the fairly simple requirements of having the header of an item in a Tree view fill all of the horizontal space available. An old problem I have faced popped up at one of new roles in the UK recently.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |