You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
3.1 KiB
136 lines
3.1 KiB
/*************************************************************************************
|
|
|
|
Toolkit for WPF
|
|
|
|
Copyright (C) 2007-2025 Xceed Software Inc.
|
|
|
|
This program is provided to you under the terms of the XCEED SOFTWARE, INC.
|
|
COMMUNITY LICENSE AGREEMENT (for non-commercial use) as published at
|
|
https://github.com/xceedsoftware/wpftoolkit/blob/master/license.md
|
|
|
|
For more features, controls, and fast professional support,
|
|
pick up the Plus Edition at https://xceed.com/xceed-toolkit-plus-for-wpf/
|
|
|
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
|
|
|
***********************************************************************************/
|
|
|
|
using System.Windows;
|
|
using System.ComponentModel;
|
|
using System.Collections.ObjectModel;
|
|
#if !OPEN_SOURCE
|
|
using Xceed.Wpf.Samples.SampleData;
|
|
#endif
|
|
|
|
|
|
namespace Xceed.Wpf.Toolkit.LiveExplorer.Samples.TokenizedTextBox.Views
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for TokenizedTextBoxView.xaml
|
|
/// </summary>
|
|
public partial class TokenizedTextBoxView : DemoView
|
|
{
|
|
#if !OPEN_SOURCE
|
|
#region Members
|
|
|
|
private static ObservableCollection<Record> m_Records;
|
|
|
|
#endregion
|
|
#endif
|
|
|
|
public TokenizedTextBoxView()
|
|
{
|
|
|
|
#if !OPEN_SOURCE
|
|
InitDataSource();
|
|
DataContext = this;
|
|
#endif
|
|
InitializeComponent();
|
|
}
|
|
|
|
#if !OPEN_SOURCE
|
|
void InitDataSource()
|
|
{
|
|
NorthwindCollections northwind = new NorthwindCollections();
|
|
m_Records = new ObservableCollection<Record>();
|
|
foreach( var employee in northwind.Employees )
|
|
{
|
|
m_Records.Add( new Record( employee.FirstName, employee.LastName ) );
|
|
}
|
|
}
|
|
|
|
|
|
public static ObservableCollection<Record> EmployeeList
|
|
{
|
|
get
|
|
{
|
|
return m_Records;
|
|
}
|
|
}
|
|
|
|
private void OnDeleteToken( object sender, RoutedEventArgs e )
|
|
{
|
|
object item = ( ( FrameworkElement )e.OriginalSource ).DataContext;
|
|
this.customTokenizedTextBox.SelectedItems.Remove( item );
|
|
}
|
|
#endif
|
|
}
|
|
|
|
#if !OPEN_SOURCE
|
|
public class Record : INotifyPropertyChanged
|
|
{
|
|
public Record()
|
|
{
|
|
}
|
|
|
|
public Record( string pFirstName, string pLastName )
|
|
{
|
|
FirstName = pFirstName;
|
|
LastName = pLastName;
|
|
}
|
|
|
|
private string m_firstName;
|
|
public string FirstName
|
|
{
|
|
get
|
|
{
|
|
return m_firstName;
|
|
}
|
|
set
|
|
{
|
|
m_firstName = value;
|
|
OnPropertyChanged( "FirstName" );
|
|
}
|
|
}
|
|
|
|
private string m_lastName;
|
|
public string LastName
|
|
{
|
|
get
|
|
{
|
|
return m_lastName;
|
|
}
|
|
set
|
|
{
|
|
m_lastName = value;
|
|
OnPropertyChanged( "LastName" );
|
|
}
|
|
}
|
|
|
|
|
|
#region INotifyPropertyChanged Members
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
protected void OnPropertyChanged( string name )
|
|
{
|
|
PropertyChangedEventHandler handler = PropertyChanged;
|
|
if( handler != null )
|
|
{
|
|
handler( this, new PropertyChangedEventArgs( name ) );
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
#endif
|
|
}
|
|
|