protected override NWidget CreateExampleContent() { NStackPanel stack = new NStackPanel(); stack.HorizontalPlacement = ENHorizontalPlacement.Left; stack.VerticalPlacement = ENVerticalPlacement.Top; stack.VerticalSpacing = 10; // Load the contry data NList <NCountry> countries = LoadCountryData(); // Create the simple combo box m_ComboBox = new NComboBox(); NPairBox pairBox = CreatePairBox("Select country:", m_ComboBox); stack.Add(new NGroupBox("Data source items -> Labels", pairBox)); // Create the simple data binding NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry> countryNameDataBinding = new NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry>(); NDataBinding.SetDataBinding(m_ComboBox.Items, countryNameDataBinding); countryNameDataBinding.DataSource = countries; countryNameDataBinding.CreateItemNode += new Function <NCreateItemNodeEventArgs <NComboBoxItem, NCountry> >(OnCountryNameDataBindingCreateItemNode); countryNameDataBinding.RebuildTarget(); // Create the advanced combo box m_AdvancedComboBox = new NComboBox(); pairBox = CreatePairBox("Select country:", m_AdvancedComboBox); stack.Add(new NGroupBox("Data source items -> Custom widgets", pairBox)); // Create the advanced data binding NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry> countryDataBinding = new NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry>(); NDataBinding.SetDataBinding(m_AdvancedComboBox.Items, countryDataBinding); countryDataBinding.DataSource = countries; countryDataBinding.CreateItemNode += new Function <NCreateItemNodeEventArgs <NComboBoxItem, NCountry> >(OnCountryDataBindingCreateItemNode); countryDataBinding.RebuildTarget(); // Select the first country m_ComboBox.SelectedIndex = 0; m_AdvancedComboBox.SelectedIndex = 0; // Subscribe to the selected index changed events m_ComboBox.SelectedIndexChanged += new Function <NValueChangeEventArgs>(OnComboBoxSelectedIndexChanged); m_AdvancedComboBox.SelectedIndexChanged += new Function <NValueChangeEventArgs>(OnComboBoxSelectedIndexChanged); return(stack); }
protected override NWidget CreateExampleContent() { NStackPanel stack = new NStackPanel(); stack.Direction = ENHVDirection.LeftToRight; stack.HorizontalSpacing = 10; // Load the contry data NList <NCountry> countries = LoadCountryData(); // Create the simple list box m_ListBox = new NListBox(); m_ListBox.Selection.Selected += new Function <NSelectEventArgs <NListBoxItem> >(OnListBoxItemSelected); stack.Add(new NGroupBox("Data source items -> Labels", m_ListBox)); // Create the simple data binding NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry> countryNameDataBinding = new NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry>(); NDataBinding.SetDataBinding(m_ListBox.Items, countryNameDataBinding); countryNameDataBinding.DataSource = countries; countryNameDataBinding.CreateItemNode += new Function <NCreateItemNodeEventArgs <NListBoxItem, NCountry> >(OnCountryNameDataBindingCreateItemNode); countryNameDataBinding.RebuildTarget(); // Create the advanced list box m_AdvancedListBox = new NListBox(); m_AdvancedListBox.Selection.Selected += new Function <NSelectEventArgs <NListBoxItem> >(OnListBoxItemSelected); stack.Add(new NGroupBox("Data source items -> Custom widgets", m_AdvancedListBox)); // Create the advanced data binding NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry> countryDataBinding = new NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry>(); NDataBinding.SetDataBinding(m_AdvancedListBox.Items, countryDataBinding); countryDataBinding.DataSource = countries; countryDataBinding.CreateItemNode += new Function <NCreateItemNodeEventArgs <NListBoxItem, NCountry> >(OnCountryDataBindingCreateItemNode); countryDataBinding.RebuildTarget(); return(stack); }