Windows app ComboBox open upwards

坚强是说给别人听的谎言 提交于 2019-12-13 06:51:16

问题


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.

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

Edit: 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?)  

回答1:


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


来源:https://stackoverflow.com/questions/28458248/windows-app-combobox-open-upwards

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!