Change position of ComboBox Dropdown list in UWP.

Henry 21 Reputation points
2021-03-16T11:39:19.19+00:00

I have a ComboBox in my UWP application and on clicking the dropdown icon the dropdown list is appearing over the Combobox.
I want the dropdown list to appear below the Combobox . I am not able to change the position of the dropdown list by modifying the ComboBox ControlTemplate in Resource Dictionary. Is it possible to change the position of dropdown list by any method?

Developer technologies | Universal Windows Platform (UWP)
Developer technologies | C++
0 comments No comments
{count} votes

Accepted answer
  1. Yan Gu - MSFT 2,676 Reputation points
    2021-03-17T06:11:05.163+00:00

    Hello,

    Welcome to Microsoft Q&A.

    The drop-down list of a ComboBox control is actual a Popup control. You could view the structure of UIElements of a ComboBox control in the default style of the ComboBox control.

    You could try to adjust the position of the Popup control in its opened event handler.

    Please check the following steps:

    a. Get the default style of ComboBox control from generic.xaml file and apply the style to your ComboBox control.
    b. Find the Popup control in the added style, and add a Opened event handler to it.
    c. Use the following code to set the VerticalOffset property of the Popup control to adjust the position:

    void winrt::BlankApp1::implementation::MainPage::Popup_Opened(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::Foundation::IInspectable const& e)  
    {  
        auto popup = sender.try_as<Windows::UI::Xaml::Controls::Primitives::Popup>();  
        popup.VerticalOffset(30);  
    }  
       
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.