开发者

How do I change the PopupAnimation in a ComboBox?

How do I change the animation in a ComboB开发者_如何学Cox for loading the popup that has the list of items? (without having to make a template for the ComboBox in order to access the popup)


To access the popup, one can do something like this:

Popup popup = (Popup)comboBox.Template.FindName("PART_Popup", comboBox);

Where obviously comboBox is your ComboBox. The key part here is that "PART_Popup" is the name of the popup in the ComboBox template (at least in the WPF toolkit).

So an example of a full piece of code, called when the ComboBox is loaded:

private void cBox_Loaded(object sender, RoutedEventArgs e)
    {
        ComboBox cBox = sender as ComboBox;
        Popup popup = (Popup)cBox.Template.FindName("PART_Popup", cBox);
        popup.PopupAnimation = PopupAnimation.Fade;
    }


Can you try this...

     <ComboBox>
         <ComboBox.Resources>
             <Style TargetType="{x:Type Popup}">
                  <Setter Property="PopupAnimation" Value="Fade" />
             </Style>
         </ComboBox.Resources>
     </ComboBox>

Let me know if this works...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜