You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For at least two controls I've noticed, if you set the Width property (in XAML), and also set the HorizontalAlignment property, Width will be ignored.
To Reproduce
Create a simple XAML page with a Grid.
Set the Width of the Page or Grid to have excess space (stretch to take up the whole page)
Add a UITextBox or ComboBox control, and set the Width as well as HorizontalAlignment:
<ui:TextBox Grid.Column="1" Grid.Row="1" Text="SomeText" Width="250" HorizontalAlignment="Left"/>
Run the app and display the page
Expected behavior
Expected: The UiTextBox or ComboBox will be the requested Width and be aligned to the left side of the containing grid.
Actual: The control is aligned to the Left but is much smaller than the set Width.
Note: You can see the problem in design mode as well, in Visual Studio 2022. Remove the HorizontalAlignment property setter and then Width is correct.
Screenshots
No response
OS version
Windows 11
.NET version
.Net 9.0
WPF-UI NuGet version
3.0.5
Additional context
The issue can be resolved by modifying the source's original Style. In the case of a TextBox, the DefaultTextBoxStyle defined in TextBox.xaml: ... <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}"> <!--- TO FIX: remove the HorizontalAlignment and VerticalAlignment setters: <Grid> --> <Border x:Name="ContentBorder" MinWidth="{TemplateBinding MinWidth}" ...
The text was updated successfully, but these errors were encountered:
Describe the bug
For at least two controls I've noticed, if you set the Width property (in XAML), and also set the HorizontalAlignment property, Width will be ignored.
To Reproduce
<ui:TextBox Grid.Column="1" Grid.Row="1" Text="SomeText" Width="250" HorizontalAlignment="Left"/>
Run the app and display the page
Expected behavior
Expected: The UiTextBox or ComboBox will be the requested Width and be aligned to the left side of the containing grid.
Actual: The control is aligned to the Left but is much smaller than the set Width.
Note: You can see the problem in design mode as well, in Visual Studio 2022. Remove the HorizontalAlignment property setter and then Width is correct.
Screenshots
No response
OS version
Windows 11
.NET version
.Net 9.0
WPF-UI NuGet version
3.0.5
Additional context
The issue can be resolved by modifying the source's original Style. In the case of a TextBox, the DefaultTextBoxStyle defined in TextBox.xaml:
... <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}"> <!--- TO FIX: remove the HorizontalAlignment and VerticalAlignment setters: <Grid> --> <Border x:Name="ContentBorder" MinWidth="{TemplateBinding MinWidth}" ...
The text was updated successfully, but these errors were encountered: