First this is my code behind:
conn.Open();
DataTable data = new DataTable();
string sql = "SELECT * FROM itemsTbl";
SQLiteCommand command = new SQLiteCommand(sql, conn);
SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
adapter.Fill(data);
cmb_items.ItemsSource = data.DefaultView;
cmb_items.DisplayMemberPath = "item_description";
cmb_items.SelectedValuePath = "item_id";
conn.Close();
And this is my xaml:
<ComboBox x:Name="cmb_items"
VerticalAlignment="Top" VerticalContentAlignment="Center"
FontSize="14"
Foreground="#666"
Height="30"
Margin="20,20,20,10"
IsEditable="True"
ItemsSource="{Binding}"
TextSearch.Text="{Binding Path=item_description}" />
It's fine and working but I would like to add some information on the combobox item so that the user would already know if there's stock or is it by packs or pcs or something like that. Also if possible, change the color of zero stock to red.
This is my current combobox:
This is my goal (photoshop):
I need the extra info only on the combobox items, but if the user clicks the item, only the item_description will show, like this:
I honestly don't know what to do here, I tried to add a combobox.itemtemplate but when I choose an item it shows "System.Data.DataRowView". Also the combobox is searchable. Should I change my approach and add the items through loop? I'm kinda new to wpf, I tried wpf before but I stopped because of busy work, so any help is really appreciated thanks!