Saturday, August 6, 2011

WPF-Basic ComboBox Example

XBAP:

<ComboBox Name="MyComboBox" Grid.Column="1" Grid.Row="2">

</ComboBox>

Code Behind:

DataTable displayformat = GetNameList();

if (displayformat.Rows.Count > 0)

{ Binding displayBinding = new Binding();

displayBinding.Source = displayformat;

MyComboBox.SetBinding(ComboBox.ItemsSourceProperty, displayBinding);

MyComboBox.DisplayMemberPath = "Name";

MyComboBox.SelectedValuePath = "ID";

}

No comments:

Post a Comment

LIveCharts2: Charts for Windows and web

Charts for Windows and web including .Net MAUI  LiveCharts - LiveCharts2 (lvcharts.com)