简体   繁体   中英

Combobox with “Select All” CheckBox in SilverLight

I've ComboBox where I am binding list which will appear with CheckBox . Now I want to add "Select All" with CheckBox and when user select that, remaining all CheckBox should get selected. Following is my code where "Select All" appears before all items but I just want it once.

CODE:

<ComboBox x:Name="SynonymsCmbBx" ItemsSource="{Binding Synonyms}" Width="250" MaxDropDownHeight="100"  Margin="0,0,375,0"  ScrollViewer.VerticalScrollBarVisibility="Auto" Visibility="Collapsed">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <CheckBox Content="Select All" Height="16" Name="checkBox1" IsChecked="True" FontWeight="Bold" />
                <CheckBox Content="{Binding Display}" Margin="10,0,0,0" IsChecked="{Binding Path=IsChecked, ElementName=checkBox1}" />
                <!--<CheckBox Content="{Binding Display}" Margin="10,0,0,0" />-->
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ComboBox>

OUTPUT:

在此处输入图片说明

Subscribe the Select All's check/selected event and using the same process used to extract the checked values from the target checkboxes; reverse the processs and set the relevant checkboxes to true or false depending on the state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM