如何更改组合框中的 PopupAnimation?

发布于 2024-11-27 11:15:59 字数 54 浏览 1 评论 0原文

如何更改组合框中的动画以加载包含项目列表的弹出窗口? (无需为组合框制作模板即可访问弹出窗口)

How do I change the animation in a ComboBox 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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

是你 2024-12-04 11:16:00

你能试试这个吗...

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

让我知道这是否有效...

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...

抹茶夏天i‖ 2024-12-04 11:15:59

要访问弹出窗口,可以执行以下操作:

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

显然,comboBox 是您的 ComboBox。这里的关键部分是“PART_Popup”是 ComboBox 模板中弹出窗口的名称(至少在 WPF 工具包中)。

这是加载 ComboBox 时调用的完整代码示例:

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;
    }

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;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文