)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to programmatically set the Width for the Popup in the AutoComplete control?

Platform: WPF |
Control: AutoComplete |
Published Date: January 29, 2015 |
Last Revised Date: June 24, 2019 |
.NET Framework: 4.5 |
Product Version: 12.3.0.36
Tags: wpf

Initially, the width for the popup is always smaller than the AutoComplete control width, but to initially increase the width for the popup, you can programmatically set the desired width for the popup.

To set the width for the popup in the AutoComplete control, get the popup from the AutoCompleteControl template and set the MinWidth for the popup.

The following code example illustrates how the popup for the AutoComplete is set narrower than the initial.

C#

// To programmatically set the PopUp Width in c#
public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
          List<String> ProductSource = new List<String>();
          ProductSource.Add("Wpf");
          ProductSource.Add("Silverlight");
          ProductSource.Add("WindowsPhone");
          this.AutoCompleteControl.CustomSource = ProductSource;
          AutoCompleteControl.Loaded += auto1_Loaded;
        }
        void auto1_Loaded(object sender, RoutedEventArgs e)
        {
            Popup pop = AutoCompleteControl.Template.FindName("PART_Popup", AutocompleteControl) as Popup;
            if (pop != null)
            {
                pop.MinWidth = 200;          
            }
        }
    }

The following screenshot illustrates the output.

PopWidth.png

Figure 1: Popup width changed

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Eric T Carter
Aug 10, 2016
i have to check this out now and come back with feedback.but l do trust this source
Reply
Emanuele Quarello
Oct 04, 2016
Could you please explain this line?
 Popup pop = AutoCompleteControl.Template.FindName("PART_Popup", Autocomplete Control) as Popup;

What "Autocomplete Control" is supposed to be?

Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon