diff --git a/LazyComboBox.WPF/LazyComboBox.WPF.csproj b/LazyComboBox.WPF/LazyComboBox.WPF.csproj index ffa676c..5899a47 100644 --- a/LazyComboBox.WPF/LazyComboBox.WPF.csproj +++ b/LazyComboBox.WPF/LazyComboBox.WPF.csproj @@ -54,7 +54,7 @@ - + Designer @@ -73,7 +73,7 @@ - + Code diff --git a/LazyComboBox.WPF/LazyComboBox.cs b/LazyComboBox.WPF/LazyComboBox.cs index 86ff4e4..13ba249 100644 --- a/LazyComboBox.WPF/LazyComboBox.cs +++ b/LazyComboBox.WPF/LazyComboBox.cs @@ -31,7 +31,7 @@ public class LazyComboBox : Control, INotifyPropertyChanged private ICollectionView _itemsView; - private LookupContext _lastContext; + private LookupContextImpl _lastContext; private int _lastIdx = -1; @@ -434,7 +434,7 @@ private IEnumerable TryLocateCandidatesByText(string text) } } - private void ExecuteLookup(LookupContext ctx, bool async = true, bool selectFirstCandidate = false) + private void ExecuteLookup(LookupContextImpl ctx, bool async = true, bool selectFirstCandidate = false) { #if DEBUG var source = new StackFrame(1).GetMethod().ToString(); @@ -449,7 +449,7 @@ private void ExecuteLookup(LookupContext ctx, bool async = true, bool selectFirs _token = new CancellationTokenSource(); var input = _textBox?.Text; - ctx = ctx ?? new LookupContext(input, _token.Token, null, this); + ctx = ctx ?? new LookupContextImpl(input, _token.Token, null, this); ListUpdating = true; Action x = () => diff --git a/LazyComboBox.WPF/LookupContext.cs b/LazyComboBox.WPF/LookupContext.cs index 469223b..897a7ce 100644 --- a/LazyComboBox.WPF/LookupContext.cs +++ b/LazyComboBox.WPF/LookupContext.cs @@ -1,64 +1,54 @@ using System.Collections; using System.Threading; -// ReSharper disable UnusedAutoPropertyAccessor.Global - namespace uTILLIty.Controls.WPF.LazyComboBox { - /// - /// The context passed to the delegate, when the - /// needs to populate the popup-list - /// - public class LookupContext - { - internal LookupContext(string input, CancellationToken token, object tag, LazyComboBox cb) - { - SelectedItem = cb.SelectedItem; - Input = input; - CancellationToken = token; - Tag = tag; - } - - /// - /// The currently selected item of the - /// - public object SelectedItem { get; private set; } - - /// - /// The user's input into the Textbox field of the - /// - public string Input { get; private set; } - - /// - /// A to periodically check for cancellation, in case the user continued - /// to enter data and a new lookup-request needs to be started - /// - public CancellationToken CancellationToken { get; private set; } - - /// - /// An arbitrary state-object which is passed on subsequent requests to , if the - /// property is set to true - /// - public object Tag { get; set; } - - /// - /// Requests the next page to be loaded, because the user has scrolled to the end of the current list and your - /// has set to true on the last run. - /// After loading the next page, you should add the newly loaded page to the end of the - /// - public bool NextPageRequested { get; internal set; } - - /// - /// The list of records returned by the delegate. The current list is also - /// pre-populated, - /// if is set to true - /// - public IEnumerable LoadedList { get; set; } - - /// - /// Set by the delegate to indicate that more records are available - /// and can be requested for the current - /// - public bool MoreDataAvailable { get; set; } - } + /// + /// The context passed to the delegate, when the + /// needs to populate the popup-list + /// + public interface LookupContext + { + /// + /// A to periodically check for cancellation, in case the user continued + /// to enter data and a new lookup-request needs to be started + /// + CancellationToken CancellationToken { get; } + + /// + /// The user's input into the Textbox field of the + /// + string Input { get; } + + /// + /// The list of records returned by the delegate. The current list is also + /// pre-populated, + /// if is set to true + /// + IEnumerable LoadedList { get; set; } + + /// + /// Set by the delegate to indicate that more records are available + /// and can be requested for the current + /// + bool MoreDataAvailable { get; set; } + + /// + /// Requests the next page to be loaded, because the user has scrolled to the end of the current list and your + /// has set to true on the last run. + /// After loading the next page, you should add the newly loaded page to the end of the + /// + bool NextPageRequested { get; } + + /// + /// The currently selected item of the + /// + object SelectedItem { get; } + + /// + /// An arbitrary state-object which is passed on subsequent requests to , if the + /// property is set to true + /// + object Tag { get; set; } + } } \ No newline at end of file diff --git a/LazyComboBox.WPF/LookupContextImpl.cs b/LazyComboBox.WPF/LookupContextImpl.cs new file mode 100644 index 0000000..fb3a24d --- /dev/null +++ b/LazyComboBox.WPF/LookupContextImpl.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Threading; + +// ReSharper disable UnusedAutoPropertyAccessor.Global + +namespace uTILLIty.Controls.WPF.LazyComboBox +{ + /// + /// The context passed to the delegate, when the + /// needs to populate the popup-list + /// + internal class LookupContextImpl : LookupContext + { + internal LookupContextImpl(string input, CancellationToken token, object tag, LazyComboBox cb) + { + SelectedItem = cb.SelectedItem; + Input = input; + CancellationToken = token; + Tag = tag; + } + + /// + /// The currently selected item of the + /// + public object SelectedItem { get; private set; } + + /// + /// The user's input into the Textbox field of the + /// + public string Input { get; private set; } + + /// + /// A to periodically check for cancellation, in case the user continued + /// to enter data and a new lookup-request needs to be started + /// + public CancellationToken CancellationToken { get; private set; } + + /// + /// An arbitrary state-object which is passed on subsequent requests to , if the + /// property is set to true + /// + public object Tag { get; set; } + + /// + /// Requests the next page to be loaded, because the user has scrolled to the end of the current list and your + /// has set to true on the last run. + /// After loading the next page, you should add the newly loaded page to the end of the + /// + public bool NextPageRequested { get; internal set; } + + /// + /// The list of records returned by the delegate. The current list is also + /// pre-populated, + /// if is set to true + /// + public IEnumerable LoadedList { get; set; } + + /// + /// Set by the delegate to indicate that more records are available + /// and can be requested for the current + /// + public bool MoreDataAvailable { get; set; } + } +} \ No newline at end of file diff --git a/LazyComboBox.WPF/GenderType.cs b/WPF.DemoApplication/GenderType.cs similarity index 74% rename from LazyComboBox.WPF/GenderType.cs rename to WPF.DemoApplication/GenderType.cs index aa7c107..ed2a5eb 100644 --- a/LazyComboBox.WPF/GenderType.cs +++ b/WPF.DemoApplication/GenderType.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace uTILLIty.Controls.WPF.LazyComboBox +namespace uTILLIty.WPF.Demo { public enum GenderType { diff --git a/WPF.DemoApplication/WPF.DemoApplication.csproj b/WPF.DemoApplication/WPF.DemoApplication.csproj index ab0ea8e..edbe3b2 100644 --- a/WPF.DemoApplication/WPF.DemoApplication.csproj +++ b/WPF.DemoApplication/WPF.DemoApplication.csproj @@ -71,6 +71,7 @@ + MainWindow.xaml Code