Hello again,
I see.
I've put together a small project to show what I want to create, and why I would like to use a Text property.
UI:
CodeBehind:
using
System;
using
System.Linq;
using
System.Windows;
using
System.Collections.Generic;
using
Telerik.Windows.Controls;
namespace
RadAutoCompleteBoxTest
{
public
partial
class
MainWindow : Window
{
List<
string
> suggestions =
new
List<
string
> {
"telerik"
,
"radautocompletebox"
,
"text property"
,
"google search box"
,
"behavior"
,
"behaviour"
,
"developer friendly controls"
,
"p0rn"
,
};
public
MainWindow()
{
InitializeComponent();
radacb.ItemsSource = suggestions;
}
private
void
RadButton_Click(
object
sender, RoutedEventArgs e)
{
string
searchString =
string
.Empty;
if
(radacb.SelectedItem !=
null
)
// does it have anything selected?
{
// get the selected value, since SearchText will NOT contain the whole string
searchString = radacb.SelectedItem.ToString();
}
else
{
// get the value from SearchText
searchString = radacb.SearchText;
}
if
(searchString.Length > 0)
{
// it's a new value, let's store it somehow
if
(!suggestions.Contains(searchString))
suggestions.Add(searchString);
RadWindow.Alert(searchString);
}
}
}
}
In codebehind, I would like to use only 1 property. (And do databinding.) For example, a Text property, that gets the whole string visible in the control. And please note the SelectionMode="Single" setter in the XAML. (The Text property would have meaning only with this set.)
I hope this clears things.
Gyula