tags:

views:

33

answers:

1

Hi

There are two issues that iam facing. One is binding a collection to combobox

In code:

private ObservableCollection<string> errList;

Initially its empty and then i add items to it.

In XAML:

<comboBox ItemsSource="{Binding errList}" IsSynchronizedWithCurrentItem="True"

Isnt this enough to get it done. But no items are seen in the combobox.

Second is toggling the visibility of the combobox when items are present.

<combobox Visibility="{ Binding ElementName=Page1, Path=ItemsPresent, Converter={StaticResource booltoVis} }"

ItemsPresent is a property which returns true of errList has items more than 0. But this is not working.

Please Help

+3  A: 

I don't think you can bind to a private field, instead after filling your collection you can do the following:

YourComboBoxName.ItemsSource = errList;

For the visibility you need to do self binding like this:

<ComboBox Visibility="{Binding Path=ItemsPresent, RelativeSource={RelativeSource Self}, Converter={StaticResource booltoVis}}"/>
A_Nablsi
+1, You can only bind to Properties. You could only bind to a private field using code behind. However, what @A_Nablsi is showing is not a "binding" but rather a simple assignment.
sixlettervariables