Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ControlTemplate and Binding problem
Message
De
28/12/2009 13:54:16
 
 
À
28/12/2009 05:00:44
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01440313
Message ID:
01440899
Vues:
31
>>>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?
>>
>>No clue, but I've seen it before. Not all the binding will be hooked up correctly.
>>
>>I'll often pull my starting template from the ControlTemplateExamples in the Windows SDK just to avoid it. But the show me the template ones are nice because they are more complete. And if you are just trying to do a minor change that a big plus.
>
>If I can't solve this I might open a MS ticket.
>Do you mind if I use your code sample (it's simpler repro code than my actual code)
>Best,
>Viv

Go for it on my sample code.

I think what is happening is that in using reflection to get the template, some of the bindings are getting evaluated and returning their value instead of the binding. Hence:

IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"

becomes:

IsChecked="False"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform