Skip to content

Commit ceaf523

Browse files
committed
Merge pull request #1797 from thoemmi/issue1764-already-loaded-controls
Subscribe to clear button even if control is already loaded. Fixes #1764
2 parents 2c445f8 + 47eb085 commit ceaf523

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

MahApps.Metro/Controls/Helper/TextBoxHelper.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,20 +374,32 @@ private static void ButtonCommandOrClearTextChanged(DependencyObject d, Dependen
374374
// only one loaded event
375375
textbox.Loaded -= TextBoxLoaded;
376376
textbox.Loaded += TextBoxLoaded;
377+
if (textbox.IsLoaded)
378+
{
379+
TextBoxLoaded(textbox, new RoutedEventArgs());
380+
}
377381
}
378382
var passbox = d as PasswordBox;
379383
if (passbox != null)
380384
{
381385
// only one loaded event
382386
passbox.Loaded -= PassBoxLoaded;
383387
passbox.Loaded += PassBoxLoaded;
388+
if (passbox.IsLoaded)
389+
{
390+
PassBoxLoaded(passbox, new RoutedEventArgs());
391+
}
384392
}
385393
var combobox = d as ComboBox;
386394
if (combobox != null)
387395
{
388396
// only one loaded event
389397
combobox.Loaded -= ComboBoxLoaded;
390398
combobox.Loaded += ComboBoxLoaded;
399+
if (combobox.IsLoaded)
400+
{
401+
ComboBoxLoaded(combobox, new RoutedEventArgs());
402+
}
391403
}
392404
}
393405

0 commit comments

Comments
 (0)