MultiSelect for WPF | ComponentOne
In This Topic
    Quick Start
    In This Topic

    This quick start will guide you through the steps of adding C1MultiSelect to a project and binding the control to a data source.

    Complete the steps given below to see how the MultiSelect control appears after data binding.

    1. Adding MultiSelect control to the Application
    2. Binding MultiSelect to a list

    The following image shows how the MultiSelect control appears after data binding.

    MultiSelect for WPF control

    Step 1: Adding MultiSelect control to the Application

    1. Create a new WPF App in Visual Studio.
    2. Drag and Drop the C1MultiSelect control from the toolbox onto the form. The following references automatically get added to the References.
      • C1.WPF.Input.4.dll
      • C1.WPF.4.dll
    3. Open MainWindow.xaml and replace the existing XAML with the following code.
      XAML
      Copy Code
      <Window
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:local="clr-namespace:MultiSelectQS_WPF"
      xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
      x:Class="MultiSelectQS_WPF.QuickStart" mc:Ignorable="d" Title="QuickStart"
      Height="386.701" Width="451.918" Loaded="Window_Loaded">
        <Grid>
              <c1:C1MultiSelect x:Name="mselect" HorizontalAlignment="Left" Height="21" VerticalAlignment="Top" Width="316" Margin="40,79,0,0"/>
        </Grid>
      </Window>
      

    Step 2: Binding MultiSelect to a list

    1. Switch to the code view and add following code to Window_Loaded event.
      Dim addressBook As IList(Of String) = New List(Of String)() From {
        "John Doe <john.doe@hotmail.com>",
        "Nancy Simmons <nsimmons@gmail.com>",
        "Henry Crews <crewsrulez@ezmail.com>",
        "Patrick Smith <psmith1988@mail.ru>",
        "Carl Collins <cc1964@facebook.com>",
        "Melody Pond <riversong@ezmail.com>",
        "Rory Williams <rorywilliams1@yandex.ru>",
        "Tracy Hobs <hobhob@protonmail.com>",
        "Sam Powell <sam.powell@ezmail.com>",
        "Charlotte Marsh <c.marsh1998@yandex.ru>",
        "Amy Berry <amyberry@mail.ru>",
        "Dante Adams <d.adams@hotmail.com>",
        "Derrick Skinner <skinner487@protonmail.com>",
        "Christina Fallon <christina.wonder@hotmail.com>",
        "Adam Johnson <johnson.adam@yahoo.com>"
      }
              
      mselect.ItemsSource = addressBook
      
      IList<string> addressBook = new List<string>()
      {
         "John Doe <john.doe@hotmail.com>",
         "Nancy Simmons <nsimmons@gmail.com>",
         "Henry Crews <crewsrulez@ezmail.com>",
         "Patrick Smith <psmith1988@mail.ru>",
         "Carl Collins <cc1964@facebook.com>",
         "Melody Pond <riversong@ezmail.com>",
         "Rory Williams <rorywilliams1@yandex.ru>",
         "Tracy Hobs <hobhob@protonmail.com>",
         "Sam Powell <sam.powell@ezmail.com>",
         "Charlotte Marsh <c.marsh1998@yandex.ru>",
         "Amy Berry <amyberry@mail.ru>",
         "Dante Adams <d.adams@hotmail.com>",
         "Derrick Skinner <skinner487@protonmail.com>",
         "Christina Fallon <christina.wonder@hotmail.com>",
         "Adam Johnson <johnson.adam@yahoo.com>"
      };
      
      mselect.ItemsSource = addressBook;
      
    2. Build and run the application.