Skip to content

Commit

Permalink
Fixed AutoSuggestion event. (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxTes authored Jun 25, 2022
1 parent f5c299b commit 06736f5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ModernWpf.Controls/AutoSuggestBox/AutoSuggestBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private void OnDelayTimerTick(object sender, EventArgs e)
if (m_delayTimer.Tag is AutoSuggestionBoxTextChangeReason reason)
{
m_delayTimer.Tag = null;
TextChanged?.Invoke(this, new AutoSuggestBoxTextChangedEventArgs(this, Text) { Reason = reason });
TextChanged?.Invoke(this, new AutoSuggestBoxTextChangedEventArgs(this, Text, reason));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Windows;
using System;

namespace ModernWpf.Controls
{
public sealed class AutoSuggestBoxQuerySubmittedEventArgs : DependencyObject
public sealed class AutoSuggestBoxQuerySubmittedEventArgs : EventArgs
{
public AutoSuggestBoxQuerySubmittedEventArgs()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Windows;
using System;

namespace ModernWpf.Controls
{
public sealed class AutoSuggestBoxSuggestionChosenEventArgs : DependencyObject
public sealed class AutoSuggestBoxSuggestionChosenEventArgs : EventArgs
{
public AutoSuggestBoxSuggestionChosenEventArgs()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Windows;

namespace ModernWpf.Controls
{
Expand All @@ -10,35 +9,21 @@ public enum AutoSuggestionBoxTextChangeReason
SuggestionChosen = 2
}

public sealed class AutoSuggestBoxTextChangedEventArgs : DependencyObject
public sealed class AutoSuggestBoxTextChangedEventArgs : EventArgs
{
public AutoSuggestBoxTextChangedEventArgs()
{
}

internal AutoSuggestBoxTextChangedEventArgs(AutoSuggestBox source, string value)
internal AutoSuggestBoxTextChangedEventArgs(AutoSuggestBox source, string value, AutoSuggestionBoxTextChangeReason reason)
{
m_source = new WeakReference<AutoSuggestBox>(source);
m_value = value;
Reason = reason;
}

#region Reason

public static readonly DependencyProperty ReasonProperty =
DependencyProperty.Register(
nameof(Reason),
typeof(AutoSuggestionBoxTextChangeReason),
typeof(AutoSuggestBoxTextChangedEventArgs),
new PropertyMetadata(AutoSuggestionBoxTextChangeReason.ProgrammaticChange));

public AutoSuggestionBoxTextChangeReason Reason
{
get => (AutoSuggestionBoxTextChangeReason)GetValue(ReasonProperty);
set => SetValue(ReasonProperty, value);
}

#endregion


public AutoSuggestionBoxTextChangeReason Reason { get; }

public bool CheckCurrent()
{
return m_source != null &&
Expand Down

0 comments on commit 06736f5

Please sign in to comment.