MaterialDesignInXAML/MaterialDesignInXamlToolkit

Disabled TextBox is not being resized correctly

Closed this issue · 1 comments

Disabled TextBoxes are not being resized properly.

Specifically, I am seeing this when a TextBox is wrapped in a ScrollViewer. In that case, when the TextBox is disabled, the TextBox's width can be increased (eg, when the top-level window is resized), but its width can then not be decreased (when the top-level window is restored to its previous size).

I've created a minimal project that demonstrates this issue:

https://github.com/philpowers/DisabledTextBoxResize

To reproduce:

  1. Verify that the TextBox resizes correctly when the "Enable TextBox" option is checked by resizing the top-level window.

  2. Uncheck the "Enable TextBox" option

  3. Resize the top-level window. The TextBox will expand when the window width is increased, but it will not shrink when the window width is decreased.

The error is here in the style:
https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/master/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml#L164
This specific attribute is preventing the sizing:
X2="{Binding ActualWidth, ElementName=border}"