MaterialDesignInXAML/MaterialDesignInXamlToolkit · info · ArgumentNullException
textBox
Error message
textBox
What it means
TextBoxHintProxy is the private adapter binding a WPF TextBox to SmartHint. Its constructor throws ArgumentNullException(nameof(textBox)) if given a null TextBox. Like the RichTextBox proxy it is a private nested class instantiated only by HintProxyFabric.Get(), which already filters nulls, so the guard is defensive and not reachable through the supported public API.
Source
Thrown at src/MaterialDesignThemes.Wpf/HintProxyFabric.TextBox.cs:24
{
private readonly TextBox _textBox;
public bool IsLoaded => _textBox.IsLoaded;
public bool IsVisible => _textBox.IsVisible;
public bool IsEmpty() => string.IsNullOrEmpty(_textBox.Text);
public bool IsFocused() => _textBox.IsKeyboardFocusWithin;
public event EventHandler? ContentChanged;
public event EventHandler? IsVisibleChanged;
public event EventHandler? Loaded;
public event EventHandler? FocusedChanged;
public TextBoxHintProxy(TextBox textBox)
{
_textBox = textBox ?? throw new ArgumentNullException(nameof(textBox));
_textBox.TextChanged += TextBoxTextChanged;
_textBox.Loaded += TextBoxLoaded;
_textBox.IsVisibleChanged += TextBoxIsVisibleChanged;
_textBox.IsKeyboardFocusWithinChanged += TextBoxIsKeyboardFocusedChanged;
}
private void TextBoxIsKeyboardFocusedChanged(object sender, DependencyPropertyChangedEventArgs e)
=> FocusedChanged?.Invoke(sender, EventArgs.Empty);
private void TextBoxIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
=> IsVisibleChanged?.Invoke(sender, EventArgs.Empty);
private void TextBoxLoaded(object sender, RoutedEventArgs e)
=> Loaded?.Invoke(sender, EventArgs.Empty);
private void TextBoxTextChanged(object sender, TextChangedEventArgs e)
=> ContentChanged?.Invoke(sender, EventArgs.Empty);
View on GitHub (pinned to 98edec3a0b)
Solutions
- Use HintProxyFabric.Get(control) instead of the private proxy constructor.
- When registering a custom builder, have the build delegate return null for unsupported/null controls rather than building a proxy with null.
Defensive patterns
Strategy: validation
Validate before calling
if (control is null) return null; var proxy = HintProxyFabric.Get(control);
Prevention
- Use HintProxyFabric.Get() rather than the private TextBoxHintProxy constructor.
- Let the fabric's built-in null guard handle null controls.
When it happens
Trigger: Only reachable via reflection over the private constructor, or if a future HintProxyFabric change bypasses its existing null check before casting the control to TextBox.
Common situations: Forking/extending the fabric or using reflection to add hint support to a custom control; ordinary SmartHint usage does not trigger it.
Related errors
AI-assisted analysis of MaterialDesignInXAML/MaterialDesignInXamlToolkit@98edec3a0b (2026-08-13).
Data as JSON: /api/errors/d045dc3cb71cacdd.
Report an issue: GitHub.