Reputation: 488
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
Upvotes: 0
Views: 57
Reputation: 89325
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!
Upvotes: 1