Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ControlTemplate and Binding problem
Message
From
27/12/2009 10:47:32
 
 
To
26/12/2009 13:55:31
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01440313
Message ID:
01440753
Views:
26
>>Hi,
>>Thank you for this. But - it doesn't work - it displays exactly the behaviour that I am seeing:
>>
>>Without the ControlTemplate clicking on the ExpanderButton in the TreeViewItem will expand the node in the tree and also fire the accessor on MyDataItem.IsExpanded.
>>
>>With the ControlTemplate in place then neither happens.....
>>
>>At least you have a reproducible case - and your test code is far simpler that the real version I'm working on so I'm going to play with that,
>>
>>Oh and, FWIW, you're using a different ControlTemplate to me (mine is the XP one - yours looks like Vista?)
>>
>>One other thing I've just noticed: If, with the ControlTemplate in place, you click on the ExpanderButton then the image toggles but the items aren't shown. Conversely, if you use the code behind button the items are shown but the ExpanderButton image doesn't change....
>>
>>
>>Best,
>>Viv
>
>Well... that's why I guessed:
>
>>>I don't get what's wrong<g>
>
>Oh... those... I didn't hook those up. Let me take a look at my code and see how it's done.
>
>Edit: On the toggle button:
>
<ToggleButton IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" Name="Expander">
Whoa. That's just a cop-out. Why should you have to mess with the ControlTemplate to get that to work.
If you run your code with NO style modifications to the TreeViewItem then the UI performs exactly as expected.
Add in my basic style with the bindings and trigger. Again the UI is fine - and the bindings now also work as expected.
But when the ControlTemplate is added to the Style then the bindings don't work. Given that the template is identical to the default why the change in behaviour?

>
>BTW I grabbed the template for AERO from ShowMeTheTemplate. Where did you get yours? The above should be the same in both, and seems to be working for me. I was just double clicking to test instead of using the expanders.

Also from ShowMeTT - but I used Luna. Main difference is in the ToggleButton - Luna has '+' and '-' as the content ; Aero uses the 'arrowhead' and rotation to indicate the Expanded state....

Best,
Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform