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

Open default email app in .NET MAUI

Sample Code:  if (Email.Default.IsComposeSupported) {     string subject = "Hello!";     string body = "Excellent!";    ...