-
Jun 9th, 2019, 09:25 AM
#1
Thread Starter
Member
[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.
-
Jun 10th, 2019, 03:41 AM
#2
Thread Starter
Member
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 ....
-
Dec 1st, 2020, 10:59 PM
#3
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|