Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This sample might help you in understanding how listbox can be used.</p> <pre><code>public class Employee { public string Name { get; set; } public string Gender { get; set; } } </code></pre> <p>XAML</p> <pre><code>&lt;StackPanel&gt; &lt;DataGrid AutoGenerateColumns="False" Name="myGrid" Margin="10"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Binding="{Binding Path=Name}" /&gt; &lt;DataGridComboBoxColumn Width="100" x:Name="Gender" SelectedValueBinding="{Binding Gender, Mode=TwoWay}" DisplayMemberPath="{Binding Gender}" /&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; &lt;Button Name="ShowPersonDetails" Content="Show Person Details" Width="200" Height="30" Click="ShowPersonDetails_Click" Margin="10" /&gt; &lt;/StackPanel&gt; </code></pre> <p>Code-behind</p> <pre><code>public partial class WPFDataGridComboBox : Window { public List&lt;Employee&gt; Employees { get; set; } public List&lt;string&gt; Genders { get; set; } public WPFDataGridComboBox() { Employees = new List&lt;Employee&gt;() { new Employee() { Name = "ABC", Gender = "Female" }, new Employee() { Name = "XYZ" } }; Genders = new List&lt;string&gt;(); Genders.Add("Male"); Genders.Add("Female"); InitializeComponent(); myGrid.ItemsSource = Employees; Gender.ItemsSource = Genders; } private void ShowPersonDetails_Click(object sender, RoutedEventArgs e) { foreach (Employee employee in Employees) { string text = string.Empty; text = "Name : " + employee.Name + Environment.NewLine; text += "Gender : " + employee.Gender + Environment.NewLine; MessageBox.Show(text); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload