We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to get selected item (not text) from TextBoxExt

Hi there,
 
In WinRt, I have successfully created a TextBoxExt instance that displays descriptions from a list of objects, but I can't figure out how to get the reference to the selected item (not text) when the user accepts the suggestion. In looking at the online documentation, it explains how to show/suggest an employee's name given a collection of employees that have Name and EmailAddress properties. How, then, in the code behind, would the code access the actual Employee object (assuming they need both the name and the email address to process whatever the user was doing)?
 
Thanks in advance for the help!

3 Replies

VV Vignesh V Syncfusion Team December 10, 2013 11:14 AM UTC

Hi Stephanie,

We have prepared a sample to address your requirement to access the Model object. In the sample we have used 'SelectedItemChanged' event and have accessed the Model object.

Please find the sample in below link,

Please let us know if you have any queries.

Regards,
Vignesh V


AC Asad Cheema February 21, 2015 08:19 PM UTC

i need to check this sample app for the siad solution, but unable to download the zip file. Giving access denied error.

Regards.


VJ Victory Jessie Selvam D Syncfusion Team February 23, 2015 09:54 AM UTC

Hi Asad,

Thank you for using Syncfusion products.

We deeply regret for the inconvenience being caused. We have prepared a sample and tried to meet your requirement. In the sample, we have retrieved SelectedItem(Model) object from SelectedItem property and e.NewValue in SelectedItemChanged event. Please download the sample from following link,

Code snippet:

<sync:SfTextBoxExt SelectedItemChanged="AutoComplete_SelectedItemChanged"  AutoCompleteSource="{Binding Sources}" AutoCompleteMode="Suggest"  SearchItemPath="Name" x:Name="textBoxExt"/>

<!--Convert the SelectedItem to string using IValueConverter-->

<TextBlock Text="{Binding ElementName=textBoxExt,Path=SelectedItem,Converter={StaticResource ModelToStringConverter},ConverterParameter=0}"/>

//SelectedItemChanged event of SfTextBoxExt

void AutoComplete_SelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

{

   if (e.NewValue != null && e.NewValue is Model)

   {

      name.Text = (e.NewValue as Model).Name;

   }

}


Sample:
AutoComplete_SelectedItem.zip

Please let us know whether the provided sample is upto your requirement or not.

Regards,
Jessie


Loader.
Live Chat Icon For mobile
Up arrow icon