Results 1 to 3 of 3

Thread: [Help needed] WPF Toolkit AutoCompleteBox

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2016
    Posts
    35

    [Help needed] WPF Toolkit AutoCompleteBox

    I've been following the example to make a simple AutoCompleteBox.

    xaml
    Code:
    <Window x:Class="Whatever.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    Title="Whatever" Height="300" Width="300">
    <Grid>
    <toolkit:AutoCompleteBox x:Name="SearchBox" HorizontalAlignment="Center" Width="200" Height="20"
    ItemsSource="{Binding Names}"
    SelectedItem="{Binding SelectedName, Mode=TwoWay}" />
    </Grid>
    </Window>
    xaml.cs
    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    
    namespace Whatever
    {
    public partial class Window1 : Window
    {
    public Window1()
    {
    InitializeComponent();
    DataContext = new ViewModel();
    }
    }
    }
    ViewModel.cs
    Code:
    using System;
    using System.Text;
    using System.Linq;
    using System.Collections.Generic; 
    
    namespace Berg
    {
    public class ViewModel
    {
    IEnumerable<string> Names { get; }
    string SelectedName { get; set; }
    
    public ViewModel()
    {
    }
    
    }
    }
    Now, I know I have to "populate" the red part but I'm lost.
    I'm not a coder nor an advanced user. I'm just trying to do this for my own humble purposes
    Can someone please help a little?
    Last edited by kmlj; Jun 10th, 2019 at 03:35 AM.

  2. #2

    Thread Starter
    Member
    Join Date
    Nov 2016
    Posts
    35

    Re: [Help needed] WPF Toolkit AutoCompleteBox

    ViewModel.cs
    Code:
    using System;
    using System.Text;
    using System.Linq;
    using System.Collections.Generic; 
    
    namespace Berg
    {
    public class ViewModel
    {
    public List<string> Names { get; set; } 
    public ViewModel()
    {
    Names = new List<string>()			
    {
       "John", "Jimmy", "James", "Jim"
    };
    }
    }
    }
    This is working just the way I want it to.
    Nevertheless, still don't know what "string SelectedName { get; set; }" is for ....

  3. #3
    Member
    Join Date
    Jul 2019
    Location
    Ahmedabad
    Posts
    57

    Re: [Help needed] WPF Toolkit AutoCompleteBox

    Hello,@kmlj
    Please follow this information, To WPF Toolkit AutoCompleteBox

    Not all the toolkit controls are included in the "main" namespace.
    Let me explain how are the toolkit dlls are built up:

    You can also install the WPF toolkit through NuGet:
    Code:
    PM> Install-Package WPFToolkit
    It will add three dlls to your project:
    WPFToolkit.dll contains the core/stable controls of the toolkit which can be found in the

    Code:
    xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    System.Windows.Controls.Input.Toolkit.dll this dll contains the preview controls like AutoCompleteBox and Rating

    The preview controls are not included in the main XML namespace so you need to use the namespace form the corresponding preview dll:

    Code:
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    
    <controls:AutoCompleteBox />
    I hope this information will be useful to you.
    Thank you.
    < advertising removed by moderator >

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width