---
title: "WPF ComboBox"  
description: "ComboBox element represents a ComboBox control in XAML.    1.Width and Height properties represent width and height of a ComboBox.2.X:Name property re"  
author: "Uttam Misra"  
published: 2011-05-05  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/156/wpf-combobox  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# WPF ComboBox

[ComboBox](https://www.mindstick.com/articles/57/display-record-according-to-combobox-selection-in-csharp-dot-net) element represents a ComboBox [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) in XAML. \

<ComboBox></ComboBox>

**1.** Width and Height [properties](https://www.mindstick.com/articles/23331/nootropics-7-different-types-and-their-unique-properties) represent [width and height](https://www.mindstick.com/forum/158680/what-css-property-is-used-to-set-the-width-and-height-of-an-element) of a ComboBox.

**2.** X:Name [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) represents the name of the control.

**3.** Margin property sets the [location](https://www.mindstick.com/blog/11636/relocating-business-or-office-to-another-location) of a ComboBox on the parent control (Location on Form or any other parent control).

**4.** **HorizontalAlignment** and **VerticalAlignment** properties are used to set horizontal and [vertical](https://www.mindstick.com/forum/12951/how-to-fix-bootstrap-tab-vertical-with-text) alignments.

**5.** The **IsSelected** property of the ComboBox control sets an item as currently selected item in the ComboBox.

```
<ComboBox Name="ComboBox1" Width="250" Height="35"          VerticalAlignment="Top" HorizontalAlignment="Right"             Margin="8,14,0,0">            </ComboBox>
```

The following line of code sets the IsSelected property of a ComboBox. \

<ComboBoxItem [Content](https://www.mindstick.com/articles/13019/get-the-best-content-marketing-pricing-packages-for-your-brand)="California" IsSelected="True" />

##### How to add items in ComboBox

ComboBox control hosts a [collection](https://www.mindstick.com/articles/1718/collections-in-java) of ComboBoxItem. The following sample code adds items to a ComboBox control at [design](https://www.mindstick.com/articles/12279/interior-design-and-furniture-store-wordpress-theme)-time using XAML. \

```
<ComboBox Margin="8,14,0,0" Name="ComboBox1" HorizontalAlignment="Right"         VerticalAlignment="Top" Width="230" Height="35">      <ComboBoxItem Content="California"></ComboBoxItem>    <ComboBoxItem Content="NY"></ComboBoxItem>    <ComboBoxItem Content="LA"></ComboBoxItem>    <ComboBoxItem Content="Texas"></ComboBoxItem>    <ComboBoxItem Content="Las Vegas"></ComboBoxItem>    <ComboBoxItem Content="Florida"></ComboBoxItem> </ComboBox>
```

---

Original Source: https://www.mindstick.com/blog/156/wpf-combobox

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
