Home » Silverlight

ComboBox Popup Direction

I have a combo box with alot of data in the items source.  Because of the amount of data when the combo box is opened the popup goes up.  But after an item is selected by an user, the next time the combobox is opened it will open down which is close to the bottom of the screen.  So, I get a little popup pointing down with a scroll bar. 

Is there any way I can force the combo box to open a certain direction, and is there a reason it opens upward initially and downward after an item is selected?

Thanks for your help.


2 Answers Found


Answer 1


I have a combo box with alot of data in the items source.  Because of the amount of data when the combo box is opened the popup goes up.  But after an item is selected by an user, the next time the combobox is opened it will open down which is close to the bottom of the screen.  So, I get a little popup pointing down with a scroll bar. 

Is there any way I can force the combo box to open a certain direction, and is there a reason it opens upward initially and downward after an item is selected?

Thanks for your help.


This is a combobox issue. Try to use a autocompletebox. Its work as a nice.


Answer 2

Hi BenFishen7

You need to set MaxDropDownHeight of combobox items. This is used to maximum height of the drop-down that lists combo box items. The default is infinity.

you can set it in constructor of your page class, but best way put it into Layout_Updated event of your class.

Ex: <ComboBox MaxDropDownHeight="double"/>
------------- Or -------------------

See the link:




is it possible to disable the popup fade effect on a ComboBox?






Normally a ComboBox positioned at the bottom of a control will open the Popup upwards if it does not fit downwards.
But if it's poistioned at the bottom of a ChildWindow it will always be opened downwards, resulting in a clipped popup where you can't see the complete list.

Is there anyway to force the popup to open upwards in this case?




The issue I've encountered goes something like this: I used a VirtualizinStackPanel in the ItemsPanelTemplate of a ComboBox because of the large number of items (in this case just simple strings) that may get displayed in the list.

        <ComboBox Height="24" Width="300" Margin="0" Grid.Row="2" Grid.Column="1">
                    <VirtualizingStackPanel />

So far so good, the items get rendered as they should, the popup opens quickly even with hunderds of items. However if I first open the popup and then after that set the SelectedItem of the ComboBox in code, not selecting one of the items on the first 'page' of the VirtualizingStackPanel, then I get the following exception when opening the popup:

Unhandled Error in Silverlight Application
Code: 4004   
Category: ManagedRuntimeError      
Message: System.ArgumentException: Value does not fall within the expected range.
   at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
   at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
   at MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, UIElement visual)
   at System.Windows.Controls.Primitives.Selector.IsOnCurrentPage(Int32 index, Rect& itemsHostRect, Rect& listBoxItemRect)
   at System.Windows.Controls.Primitives.Selector.ScrollIntoView(Int32 index)
   at System.Windows.Controls.Primitives.Selector.SetFocusedItem(Int32 index, Boolean scrollIntoView)
   at System.Windows.Controls.ComboBox.ArrangePopup()
   at System.Windows.Controls.ComboBox.ElementPopupChild_SizeChanged(Object sender, SizeChangedEventArgs e)
   at System.Windows.FrameworkElement.OnSizeChanged(Object sender, SizeChangedEventArgs e)
   at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)

This exception does not happen when you set the SelectedItem to one of the Items that are not virtualized. Also if you set the SelectedItem before opening the popup for the first time the error does not seem to occur.

I think this is a bug in Silverlight 4, but I have not found any other references to this issue. Has anyone seen this before and is there a possible workaround - apart from not using the VirtuallizingStackPanel?



I have a ComboBox which display list of item, each item has two properties: Name and Type.

I want to display only the name inside the selected combo box item (the item which is display when the combo box is closed) and both the name and the type on the popup items list.

I've use the following Style and DataTemplate on the ComboBox:


<Stylex:Key="OrgUnitComboItemStyle"TargetType="ComboBoxItem"><SetterProperty="HorizontalContentAlignment"Value="Stretch"/></Style><DataTemplatex:Key="OrgUnitComboTemplate"><GridBackground="Green"HorizontalAlignment="Stretch"><Grid.ColumnDefinitions><ColumnDefinitionWidth="7*"/><ColumnDefinitionWidth="3*"/></Grid.ColumnDefinitions><TextBlockGrid.Column="0"Text="{Binding Name}"/><TextBlockGrid.Column="1"Text="{Binding Type}"/></Grid></DataTemplate></Grid.Resources>

The problem is that the popup items display as needed but when I select an item the OrgUnitComboItemStyle seem to NOT apply to it and the name TextBlock right next to the type TextBlock.


I'm willing to display both the name and the type on the selected item but I want to have some space between them.

What is the style that is applied to the selected ComboBoxItem?


Thank you,



I have created a usercontrol with around 8 buttons. A small popup is opened when the user click any of these buttons.

The popup must be closed when the focus moves out of the usercontrol.

From the usercontrol, the focus only allowed to go to the Popup, in all other cases popup must be closed.

I am looking for a solution in the usercontrol level.

The sample application attached here for your reference.

Please give your valuable feedback. Thanks in advance.


Hi All,

From my main page when I click a button onclick event calls a javascript function that opens a popup window:

function OpenTest1AWindow()
				window.open("test1A.aspx",null,"width=1000,height=800,top=100,left=150, scrollbars=yes");


On the popup window named test1A there is a datagrid that has an ImageButton . When it is clicked the onclick event supposed to open the new page (Test2B ) on a brand new popup window but instead the page opens on the existing popup window (Test1A ).


How can I make Test2B open in a new popup window instead of using the popup window that has Test1A page.




 I have an aspx page which contains a user control(a gridview). When I click on a link button in the gridview, I will open a popup window(An aspx page) successfully. When I click on save button in the popup, I am saving the details and refreshing the parent page successfully. I have a button in popup window. My requirement is:

When I click on the button inside popup window1, I would like to open another popup(aspx)(Say popup window2) in a new window without closing popup window1. When I save some changes in popup window2 and click on save button in popup window2, I need to close it and refresh popup window1.

How can I ahieve this?



I have one page with a panel that makes up my ModalPopup. On the ModalPopup there is an updatepanel with a textbox and a button in it.

There is a textbox on the "parent" page and I want to click the button on the modalpopup and move the data from the popup textbox to the parent textbox. So far, no joy. I have a line in the code behind to move the data between textboxes and I have also tried javascript to do the same thing but I am not able to make this happen unless i click the button twice.

Any help is appreciated.


Hello everybody.

I want to call a popup window say win2 from another popup window win1.

The calling of win1 is :

<script type="text/javascript">
function openPopUp(){
               window.open("LeaveApplicationForm.aspx", "Leave Application Form", "status = 1, height = 800, width = 600"); } </script>

And in page load :

SubmitButton.Attributes.Add("onclick" , "openPopUp()");

This is working fine.

Now for win2 the calling function is :

try {              
              Response.Write("<script language='javascript'> { window.open('EmailSendReport.aspx?Report=Success','Email Report Form', 'status = 1, height = 500, width = 500');}</script>");
} catch (Exception) {
              Response.Write("<script language='javascript'> { window.open('EmailSendReport.aspx?Report=Failure','Email Report Form', 'status = 1, height = 500, width = 500');}</script>");

This piece of code is place in CS script of win1, and at the end I want to close win1 so I placed :

Response.Write("<script language='javascript'> { window.close();}</script>");

at the end the win1's CS script.

Now the problem is if I do not call win2 popup the win1 aromatically closing after doing its job. But if I call win2 then it is not closing.

Also if I want to close win2 after thread sleep of 6000 the reoprt label placed in win2 don't displaying any text.

The CS script of win2 is :

        protected void Page_Load(object sender, EventArgs e) {
		String Report = Request.QueryString["Report"];

		if (Report.Equals("Success")) {
			Page.Title = "Success Report";
			ReportLabel.Text = "Email Successfully Send";
		} else {
			Page.Title = "Failure Report";
			ReportLabel.Text = "Email Sending Failed";
		Response.Write("<script language='javascript'> { window.close();}</script>");

This win2 is closing after 6000 but without displaying anything. What I am doing wrong?

Please help.

Thank you.


Hi All,

I have Popup instance of thi class


when I set the isOpen property to true then Popup become visible (on some action I want to show Popup e.g. button click). My problem is when I need to hide Popup. I can hide popup by setting isOpen to false (for example in button action) but I want to hide Popup after 5 secs not on button action. So is there a way to do this ? I want to achieve non blocking state where I have main form with Popups in Right bottom corner of desktop (like Skype popups). I tried to make this by use some threading stuff but I stoped when I got "The calling thread cannot access this object because a different thread owns it."

This is my class for popup (in develop):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls.Primitives;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows;
using System.Diagnostics;
using System.Threading;

namespace PomodoroT
  class PomodoroPopUp : Popup
    privatestring title = "Pomodoro started";
    privatestring message = "Have a great pomodoro! You have\n25 minutes to do 'Some description'";
    private Image img = null;

    private DockPanel dockPanel;

    public PomodoroPopUp()

      dockPanel = new DockPanel();
      dockPanel.Background = Brushes.Bisque;
      dockPanel.Width = 300;

      TextBlock titleBlock = new TextBlock();
      titleBlock.FontWeight = FontWeights.Bold;
      titleBlock.Text = title;

      TextBlock msgBlock = new TextBlock();
      msgBlock.Text = message;

      img = new Image();
      img.Width = 48;
      img.Height = 48;

      System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(

      img.Source = bitmapSource;

      DockPanel.SetDock(img, Dock.Left);

      DockPanel.SetDock(titleBlock, Dock.Top);
      DockPanel.SetDock(msgBlock, Dock.Bottom);

      this.Child = dockPanel;
      this.PopupAnimation = System.Windows.Controls.Primitives.PopupAnimation.Fade;
      this.AllowsTransparency = true;

      Rect rect = new Rect(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width,
        System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - 200, 300, 50);
      this.PlacementRectangle = rect;


    publicvoid show()
      this.IsOpen = true;
      Thread t = new Thread(hide);

    privatevoid hide() {
      this.IsOpen = false;


this is ho I create popup and show:

privatevoid button1_Click(object sender, EventArgs e)
      PomodoroPopUp pop = new PomodoroPopUp();

Showing works but I dont know how to hide this after 5 seconds in non blocking other GUI.

Thank you for any hint.


Hi everyone,

I'm creating for windows phone 7.

This application has a button create item.

This button open a user control in a popup. This user control contain the interface to create the new item.

In the item contains a date of creation. To display the date I use the DatePicker control from the WP7 toolkit:http://silverlight.codeplex.com/releases/view/52297

But the problem is that this control is also a popup and so the popup of the date picker is displaying under my control for creating the new item.

So my question is : How can I make the popup showed on top?

Here is the code that enable me to display the popup.

public event EventHandler Closed;

        internal Popup ChildWindowPopup
            private set;

        private static PhoneApplicationFrame RootVisual
                return Application.Current == null ? null : Application.Current.RootVisual as PhoneApplicationFrame;
 public void Show()
            if (this.ChildWindowPopup == null)
                this.ChildWindowPopup = new Popup();


                    this.ChildWindowPopup.Child = this;
                catch (ArgumentException)
                    throw new InvalidOperationException("The control is already shown.");

            if (this.ChildWindowPopup != null && Application.Current.RootVisual != null)
                //SystemTray.IsVisible = false;
                // Show popup
                this.ChildWindowPopup.IsOpen = true;

            if (RootVisual != null)
                // Hook up into the back key press event of the current page
                ((PhoneApplicationPage)RootVisual.Content).BackKeyPress += new EventHandler<System.ComponentModel.CancelEventArgs>(FindPeople_BackKeyPress);

Function for popup are the same for each control.

Any help will be really welcomed.


I'm developing a wpf windows app ( my first one ) and I can't manage to solve this problem I have.

Take two  comboboxes, each with the selectedValue bound to a path in the window's DataContext. The DataContext is set to a table in a DataSet.

SelectedValue="{Binding Path=brandID}"
SelectedValue="{Binding Path=modelID}"
And on the window loaded event I setup the ItemsSource for them:
privatevoid Window_Loaded(object sender, RoutedEventArgs e) 
this.DataContext = this.ProductsDataSet.products; 
// Lookup values from all brands
this.ddlBrand.ItemsSource = this.ProductsDataSet.brands;  
// Lookup values from all models
this.ddlModel.ItemsSource = this.ProductsDataSet.models;  
// setting up the CollectionView
this.view = (CollectionView)CollectionViewSource.GetDefaultView(this.ProductsDataSet.products);        

What I need is when I select a value from ddlBrand, the values in ddlModel to be limited to the ones available to the specific brand selected. In the same time, the SelectedValue for the models ( which is of type int) is to be set to the value in the products table.
I've tried to implement this in several ways ( setting up the ItemsSource ddlModel on the SelectionChanged event of ddlBrand, setup a CustomFilter for the BindingListCollectionView of ddlModel - in the same event, the previous 2 versions in different events and variations etc. ) no success. Everytime I modify the source or the view of ddlModel the SelectedValue binding setup in XAML is lost ( I've tried rebinding in code) . Everytime I change the product I'm viewing the selection in ddlModel is lost.
I believe this is a simple common task, so there must be something I'm missing.  It's been almost 2 days since I'm strugling with this ( productive, huh? ). Can someone share some knowledge?

PS: The data is taken from an access database. DataSet created with drag and drop in the designer. Tables: products(productID, brandID, modelID, version, etc), brands (brandID, brandName), models (modelID, modelName ) . The navigation is like in How Do I: Create a Simple Data Entry Form in WPF



I am trying to change the displayed value of a comboBox based on the value of another comboBox at the click of a button.  Both comboBoxes are already populated.

I am using C# language.  Here is a code snippet:

private void updateButton_Click(object sender, EventArgs e)
       if (Text.(this.floorComboBox.Text) == FloorName1)
        this.beamComboBox.Text = "BeamName1";
but an error is coming up on Parse and I'm not sure whether the code is correct anyway.

Any help appreciated.

Best regards,



Hi everybody!

I'm developing a WPF application that needs a combobox updating another combobox items when selection changes.

I isolated the code and the problem is still there, when i change the first selection and then click the other it takes a lot of time (IMHO) 


namespace TestCombobox
 ///<summary>/// Interaction logic for MainWindow.xaml///</summary>publicpartialclass MainWindow : Window
  private List<string> methodsList;
  private Dictionary<string, List<string>> dict;

  public MainWindow()

   dict = new Dictionary<string, List<string>>();

   for(int i=0; i<20; i++){
    List<string> current = new List<string>();
    dict.Add(i.ToString(), current);
    for (int j = 0; j < 10; j++)
     current.Add(new StringBuilder().AppendFormat("{0} - {1}", i, j).ToString());

   types.ItemsSource = dict.Keys;
   types.SelectedIndex = 0;
   dict.TryGetValue(types.Items[0] asstring, out methodsList);
   methods.ItemsSource = methodsList;

  privatevoid types_SelectionChanged(object sender, SelectionChangedEventArgs e)
   dict.TryGetValue(types.Items[((ComboBox)sender).SelectedIndex] asstring, out methodsList);
   methods.ItemsSource = methodsList;


And its XAML:


Anyone knows why it's so slow?



Is there a simply way to can change the Combobox drop down box's background without override whole combobox controltemplate?

the default combobox dropdown box background is white. we like to customize it. thx!




How to update data of a ComboBox after selecting an item in another ComboBox. My application is a Silverlight Business Administration and I do not use the design patternMVVM (I try to learn).

Each ComboBox is filled with a query(Ria Service).

There is a way to do that.



I am trying subcategory datagridviewcombobox column changed items based on category combobox selected value.. any help me


thanks in advance...

I use the Powerpoint Object-Model to programmatically create a presentation in PowerPoint 2007.

Some of the computers on which I run my program have PowerPoint set with Hebrew as the Primary Editing Language.
(to change the primary language, push the "Office" button, then "Powerpoint options", and go to Popular->Language Settings->Primary Editing Language)

On these computers, when I run my program, all the text in the created presentation (wrongly) appears right-justified and the bullets appear to the right of the text.

I could fix this by editing the ppt/presentation.xml in the resulting presentation PPTX file.  I adjust the Alignment and RightToLeft properties in the "Default Text Styles" for each bullet level. However, XML editing is not a good option for this project.

How can I change the default text direction in a presentation using the Object Model (i.e., VBA), besides changing each TextBox individually?


Hi all,

I have problem to change direction of the textbox,  i need to change the driction as bottom to top.

But in report has provide the tb-rl and tb-lr. these are changed the direction as top to bottom.

anybody worked on it , please help.


Murugan A


Hi, I hope you will tolerate a very unsophisticated post... or refer me to the right forum... I need a little expert advice.

My company provides academic tutoring, and I developed a process that we use to grade students' tests. The process is very methodical and repetitive and involves two pieces of software: one is Remark OMR (optical mark recognition), and the other is MS Excel. We scan students' tests into the computer; Remark reads the images and interprets them as data; it exports the data to an existing Excel workbook that I made, which then turns the data into a score report.

Although the process is predictable and repetitive, it does have a lot of steps, creating a lot of opportunities for mistakes by the various teachers. So I would like to create a very simple program that can take care of the whole process. Ideally, I'd like to have a window that just asks for the student's name and which test (s)he took, and the program would take care of the rest.

I am not a programmer, but I am a generally smart person who actually did take some programming classes back in college, so I figure if it can be done, I can learn how to do it. I just need to know whether it's possible and what general process I would use to develop it--Visual Basic? I don't want to waste time going down the wrong path.

Specifically, here are some important things the program would need to be able to do:

Determine if the student already has an Excel workbook with his name, and if not, create one by copying and renaming the template. Start the Remark program and open the right document based on which test was taken. Tell the Remark program to read the correct image, which would be the most recently created one in a certain folder. Tell Remark to export the data to the proper Excel workbook, based on the student's name Open the Excel Workbook, navigate to the right worksheet, and enter a few pieces of data (name & date) into specified cells. Print, save, and close all the software.


Can Visual Basic (or any other development platform) make decisions and direct other software in this way? Please help -- I'm a little overwhelmed. Thanks! Dave


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure