private void OnCountryNameDataBindingCreateItemNode(NCreateItemNodeEventArgs <NComboBoxItem, NCountry> args) { // Create a combo box item for the current country NCountry country = args.Item; args.Node = new NComboBoxItem(country.Name); }
private void OnCountryDataBindingCreateItemNode(NCreateItemNodeEventArgs <NComboBoxItem, NCountry> args) { NCountry country = args.Item; // Create a stack panel NStackPanel stack = new NStackPanel(); stack.Padding = new NMargins(3); stack.Tag = country; // Create the flag image box and the country name label NLabel countryLabel = new NLabel(country.Name); countryLabel.VerticalPlacement = ENVerticalPlacement.Center; countryLabel.Font = new NFont(NFontDescriptor.DefaultSansFamilyName, 10, ENFontStyle.Bold); NImageBox imageBox = new NImageBox(country.Flag); imageBox.VerticalPlacement = ENVerticalPlacement.Center; imageBox.HorizontalPlacement = ENHorizontalPlacement.Left; NPairBox pairBox = new NPairBox(imageBox, countryLabel); pairBox.Spacing = 3; stack.Add(pairBox); // Create the capital label NLabel capitalLabel = new NLabel("Capital: " + country.Capital); stack.Add(capitalLabel); // Create the currency label NLabel currencyLabel = new NLabel("Currency: " + country.CurrencyName + ", " + country.CurrencyCode); stack.Add(currencyLabel); // Create a combo box item to host the created widget NComboBoxItem comboBoxItem = new NComboBoxItem(stack); comboBoxItem.Text = country.Name; args.Node = comboBoxItem; }