问题
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