diff --git a/NZazu/Fields/NZazuAutocompleteField.cs b/NZazu/Fields/NZazuAutocompleteField.cs index fe30359..69f1c90 100644 --- a/NZazu/Fields/NZazuAutocompleteField.cs +++ b/NZazu/Fields/NZazuAutocompleteField.cs @@ -12,6 +12,7 @@ namespace NZazu.Fields internal class NZazuAutocompleteField : NZazuField { private readonly IProvideSuggestions _suggester; + private bool _suggesterAttached; public NZazuAutocompleteField(FieldDefinition definition, Func serviceLocatorFunc) : base(definition, serviceLocatorFunc) @@ -37,14 +38,20 @@ protected override Control CreateValueControl() // we have to do this on load because some wpf stuff does not work if no parent is set // i.e. some popup magic on window - result.Loaded += (sender, args) => { AttachSuggestor(sender); }; + result.Loaded += (sender, args) => + { + if (_suggesterAttached) return; + _suggesterAttached = true; + + AttachSuggester(sender); + }; return result; } - private void AttachSuggestor(object sender) + private void AttachSuggester(object sender) { -// no suggester, no suggestions ;) + // no suggester, no suggestions ;) if (_suggester == null) return; var tb = (TextBox) sender; @@ -59,4 +66,4 @@ private void AttachSuggestor(object sender) manager.AttachTextBox(tb); } } -} \ No newline at end of file +}