![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Bound HeaderedItemsControls inherit ItemContainerStyle differently from unbound controls? Has anyone tried to use nested ItemContainerStyles in bound scenarios using TreeViewItems or MenuItems? Consider the following XAML: <Window x:Class="WindowsApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/avalon/2005" xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005" Title="WindowsApplication1" > <Window.Resources> <XmlDataProvider x:Key="Data" XPath="Items"> <Items xmlns=""> <Child text="Child"> <Grandchild text="Grandchild"> <Grandchild text="Shouldn't see this" /> </Grandchild> </Child> </Items> </XmlDataProvider> <Style x:Key="ChildTemplate" TargetType="{x:Type HeaderedItemsControl}"> <Setter Property="Background" Value="Green" /> <Setter Property="ItemContainerStyle" Value="{StaticResource GrandchildTemplate}" /> </Style> <Style x:Key="BoundChildTemplate" TargetType="{x:Type HeaderedItemsControl}" BasedOn="{StaticResource ChildTemplate}"> <Setter Property="Header" Value="{Binding XPath=@text}" /> <Setter Property="ItemsSource" Value="{Binding XPath=Grandchild}" /> </Style> <Style x:Key="GrandchildTemplate" TargetType="{x:Type HeaderedItemsControl}"> <Setter Property="Background" Value="Orange" /> </Style> </Window.Resources> <DockPanel> <TreeView DockPanel.Dock="Top"> <TreeViewItem Header="Bound" ItemsSource="{Binding Source={StaticResource Data}, XPath=Child}" ItemContainerStyle="{StaticResource BoundChildTemplate}" /> <TreeViewItem Header="Unbound" ItemContainerStyle="{StaticResource ChildTemplate}"> <TreeViewItem Header="Child"> <TreeViewItem Header="Grandchild" /> </TreeViewItem> </TreeViewItem> </TreeView> </DockPanel> </Window> The basic scenario here is a TreeView with two TreeViewItems in the root (same behaviour happens if you replace "TreeView" with "Menu"), one of which is bound to a datasource, and one of which has its items specified manually. Both root items have an ItemContainerStyle set -- the bound item's container style is based on the unbound one, but adds some recursive binding goop. The end result of this mark-up should be that both the bound and unbound items look exactly the same: they should both contain a green child that says "Child", which contains an orange child that says "Grandchild". The unbound item behaves as expected, but the bound one does not. All of the bound item's descendents apparently get the same ItemContainerStyle, and I can't seem to find a way to override it in the middle. It contains three nested, green children, the third of which is the "Shouldn't see this" element in the XML, which shouldn't be displayed because the grandchild ItemContainerStyle doesn't have any binding information. Am I missing something? Is this a bug? This is in the November '05 CTP. Thanks in advance! -- Ryan Milligan |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Where is the data bound combo box like in vb6? | bill | .NET General | 2 | 07-22-2008 09:35 PM |
| How reflect the changes in array to bound grid | Latha | .NET General | 1 | 03-19-2008 12:54 PM |
| inherit controls in WPF | Yoavo | Avalon | 1 | 10-09-2007 10:59 AM |
| Are licenses language-bound? | Rain in Spain | Vista installation & setup | 8 | 02-06-2007 10:05 AM |