Windows应用程序ComboBox向上打开 [英] Windows app ComboBox open upwards

查看:72
本文介绍了Windows应用程序ComboBox向上打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows应用程序中获取 ComoboBox 向上打开而不是向下打开。我已经阅读过有关在WPF中执行此操作的信息,但显然语法有所不同。我试过修改 ComboBox ControlTemplate ,但是我不确定我应该修改哪个属性

I am trying to get a ComoboBox in a Windows App to open upwards instead of downwards. I've read about doing this in WPF but obviously the syntax is a little different. I've tried modifying the ControlTemplate of the ComboBox but I am not sure exactly what property I am supposed to be modifying.

对于 Windows应用 code,有简单的方法吗?

Is there an easy way to do this for a Windows App?

编辑:当我尝试应用Florian的修复程序时,出现以下构建错误:

When I try to apply Florian's fix, I get the following build error:

Error   1   'Windows.UI.Xaml.Controls.ControlTemplate' does not contain a definition for 'FindName' and no extension method 'FindName' 
accepting a first argument of type 'Windows.UI.Xaml.Controls.ControlTemplate' could be found (are you missing a using directive or an assembly reference?)  


推荐答案

在加载组合时调用此方法:

Call this method when the combo is loaded :

    private void myCombo_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
        ControlTemplate ct = this.myCombo.Template;
        Popup pop = ct.FindName("PART_Popup", this.myCombo) as Popup;
        pop.Placement = PlacementMode.Top;
    }

这篇关于Windows应用程序ComboBox向上打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆