Question

ListBoxItem property "IsSelected" binds to boolean property of my class.

public class TaxModel
{
    [XmlElement("id")]
    public int ID { get; set; }

    [XmlElement("isTaxInclusive")]
    public bool IsTaxInclusive { get; set; } // IsSelected
}

I set CustomerTaxesListBox.ItemsSource = List<"TaxModel> and some of them have IsTaxInclusive = true.

My question is:

When CustomerTaxesListBox.Visibility = Visibility.Collapsed, I can't get CustomerTaxesListBox.SelectedItems (It's empty). If ListBox is visible I can get SelectedItems

Was it helpful?

Solution

Here is an idea for workaround : You can query from List<TaxModel> to get only TaxModel's having IsTaxInclusive value = true, because IsSelected is bound to IsTaxInclusive. And getting Items having property IsSelected = true is the same as getting SelectedItems.

Try it out, hope that works!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top