Intersoft.Client.Framework Namespace : ISMultipleSelectionControl Class |
Public MustInherit Class ISMultipleSelectionControl Inherits ISSelectionControl Implements IControl, IFramework, IItemsControl, IMultipleSelection, ISelection
Dim instance As ISMultipleSelectionControl
public abstract class ISMultipleSelectionControl : ISSelectionControl, IControl, IFramework, IItemsControl, IMultipleSelection, ISelection
public ref class ISMultipleSelectionControl abstract : public ISSelectionControl, IControl, IFramework, IItemsControl, IMultipleSelection, ISelection
The base class for multiple selection controls in ClientUI is ISMultipleSelectionControl. This class inherits ISSelectionControl and defines SelectedItems property which you can also bind using MVVM pattern. This property indicates the current selected items and also can be used to define the selected items.
When this property is changed, it means that the current selection has changed. Consequently, it will synchronize all selection related properties, including updating the IsSelected property for each item.
You can change the selection by replacing the SelectedItems property, or adding and removing the items from the current SelectedItems collection.
The following example shows how to work with SelectedItems property.
XAML |
Copy Code
|
---|---|
<Intersoft:DockPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <Intersoft:UXListBox x:Name="ListBox1" HorizontalAlignment="Center" VerticalAlignment="Center" SelectionMode="Extended"> <Intersoft:UXListBoxItem Content="Item #1" IsSelected="True"/> <Intersoft:UXListBoxItem Content="Item #2" IsSelected="True"/> <Intersoft:UXListBoxItem Content="Item #3"/> <Intersoft:UXListBoxItem Content="Item #4"/> </Intersoft:UXListBox> <Intersoft:FieldLabel Intersoft:DockPanel.Dock="Top" Header="SelectedIndex"> <TextBlock Text="{Binding SelectedIndex, ElementName=ListBox1}" Margin="4"/> </Intersoft:FieldLabel> <Intersoft:FieldLabel Intersoft:DockPanel.Dock="Top" Header="SelectedItem"> <TextBlock Text="{Binding SelectedItem.Content, ElementName=ListBox1}" Margin="4"/> </Intersoft:FieldLabel> <Button Intersoft:DockPanel.Dock="Top" Content="Change Selected Items" Margin="4" Click="Button_Click"/> </Intersoft:DockPanel> |
C# |
Copy Code
|
---|---|
private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { ObservableCollection<object> selectedItems = new ObservableCollection<object>(); selectedItems.Add(this.ListBox1.Items[0]); selectedItems.Add(this.ListBox1.Items[3]); this.ListBox1.SelectedItems = selectedItems; } |
This sample demonstrates that when you perform multiple selection, such as by holding Shift or Ctrl key, the SelectedItems property will be updated. You can also change the selected items by changing this SelectedItems property as demonstrated when you click the button.
System.Object
System.Windows.DependencyObject
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
System.Windows.Controls.ItemsControl
Intersoft.Client.Framework.ISItemsControl
Intersoft.Client.Framework.ISSelectionControl
Intersoft.Client.Framework.ISMultipleSelectionControl
Intersoft.Client.UI.Controls.Interactivity.ISDragableMultipleSelectionControl
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2