views:

8

answers:

0

Ok, this is sort of a follow-up to my first question http://stackoverflow.com/questions/3827701/modify-or-tweak-an-existing-treeviewitem-control-template but since it is technically a new question, I'm told a good S/O visitor should create a new one, so here it is!

Ok... the existing template for a TreeViewItem is based on a grid, a border, a contentpresenter (PART_Header) and an itemspresenter (ItemsHost). It also has a toggle button used to show the expanded state of the node which has its own control template but which is apparently stored in the same place as the TreeViewItem's style itself.

Now we want to change the layout of a TreeViewItem but we want to keep the existing style of the toggle button as defined by the theme. Problem is per this article, http://msdn.microsoft.com/en-us/library/ms788727.aspx, and more specifically this line...

<ToggleButton x:Name="Expander"
    Style="{StaticResource ExpandCollapseToggleStyle}"
    IsChecked="{Binding Path=IsExpanded,
    RelativeSource={RelativeSource TemplatedParent}}"
    ClickMode="Press" />

...the style/template for the button is a local resource called 'ExpandCollapseToggleStyle' which we can't get to. Is there any way we can capture that style before replacing the template for the TreeViewItem since we do want to keep that working and looking exactly as expected? While we could just grab the style from that page as-is, I'm concerned doing so we will lose the control's ability to use the theme's defined visual appearance for the controls (i.e. in Win7 it's a triangle whereas in an XP 'classic' theme it should look like a box with either a plus or minus in it.)

Also, as a side-note, why do you think they put the ClickMode="Press" there where it's instantiated rather than as a setter in the ExpandCollapseToggle style in the first place? Just wondering about that.