I have two listboxes with categories and subcategories. I would like subcategories popup when a category is clicked once.
Even though my code works with mouse double-click event, I couldn't work it out with one click. I tried mouse down, mouse up preview mouse down etc. They all give null reference error
private void DataCategoryListBox_PMouseLDown(object sender, MouseButtonEventArgs e)
{
string selectedCat = DataCategoryListBox.SelectedItem.ToString();
MessageBox.Show(selectedCat);
if (selectedCat == "Geological")
{
string[] GeoCats = { "soil", "hydrogeology" };
SubCatListBox.ItemsSource = GeoCats;
}
}
Is there a solution to this?