WPF and Silverlight.ComboBox 如何經過 Binding IsDropDownOpen 實現下拉菜單展開

In the WPF example the Popup and the ToggleButton (the arrow on the right) are bound with the property IsDropDownOpen:spa

 在模版裏面設置code

<Popup IsOpen="{TemplateBinding IsDropDownOpen}" ... <ToggleButton IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ...

A class Popup has the property StaysOpen that isn't specified in the standard template of a ComboBox and has a default value true. It follows that there is a subscription to the LostFocusevent in the internal implementation of a ComboBox, that sets IsDropDownOpen=false every time when the control lose a focus.ip

Silverlight has no bindings in xaml, but you will find the same sequence if you open the assembly in .Net Reflector.ci

相關文章
相關標籤/搜索