Question

Evening all, I have a basic autocompletebox using silverlight5. The aim is to be able to search through a list of people and remove certain people from this list via checkboxes above. On the checkbox event the list is modified but this is not reflected in the autocompletebox.

.xaml:

<StackPanel Orientation="Vertical" x:Name="LayoutRoot" Background="Transparent">
    <sdk:Label Content="Filter By:" FontSize="12" Name="label1" Margin="10,10,10,5" />
    <CheckBox Content="Students" Height="16" Name="checkBox1" Margin="10,5,10,0" Checked="checkBox1_Checked" Unchecked="checkBox1_Checked"/>
    <CheckBox Content="Staff" Height="16" Name="checkBox2" Margin="10,5,10,0" Checked="checkBox2_Checked" Unchecked="checkBox2_Checked"/>
    <CheckBox Content="Guest" Height="16" Name="checkBox3" Margin="10,5,10,10" Checked="checkBox3_Checked" Unchecked="checkBox3_Checked"/>
    <sdk:AutoCompleteBox x:Name="peoplelist"/>
</StackPanel>

Code behind:

public CustomerFilterControl()
    {
        InitializeComponent();
        //_viewModel.Initialize(); initial loading of context data, populate dropdowns etc
        people.Add("Student 1");
        //.....................add more
        peoplelist.Itemssource = people;
    }

Checkbox methods:

private void checklist()
    {
        if (checkBox1.IsChecked.Value)
        {
            people.Clear();
            people.Add("Guest 1");
            //.................... add more
            peoplelist.DataContext = people;
    }

Lots of searching has pointed me to many work around for earlier versions of sliverlight but I'm practically going around in circles at this point.

Could anyone point me in the right direction to getting this functioning?

Was it helpful?

Solution

Replace List<string> by ObservableCollection<string>

This generic raises the CollectionChangedEvent so bound controls know they need to update.

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