dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.27k stars 1.76k forks source link

[WinUI] Editor width is not updated when setting styles for native view #25684

Open Lakshminatarajan opened 3 weeks ago

Lakshminatarajan commented 3 weeks ago

Description

We are using editor with custom style to disable the border of the editor. This customization affects the border to be width to be filled to the available screen width. The editor layout to the placeholder's size.


  public class CustomStyleEditor : Editor

    {

#if WINDOWS

        private void ApplyTextBoxStyle(Microsoft.UI.Xaml.Controls.TextBox? textbox)

        {

            var textBoxStyle = new Microsoft.UI.Xaml.Style(typeof(Microsoft.UI.Xaml.Controls.TextBox));

            textBoxStyle.Setters.Add(new Microsoft.UI.Xaml.Setter() { Property = Microsoft.UI.Xaml.Controls.Control.BorderBrushProperty, Value = new Microsoft.UI.Xaml.Media.SolidColorBrush(Windows.UI.Color.FromArgb(0, 0, 0, 0)) });

            textBoxStyle.Setters.Add(new Microsoft.UI.Xaml.Setter() { Property = Microsoft.UI.Xaml.Controls.Control.BorderThicknessProperty, Value = new Thickness(0) });

            textbox!.Resources.Add(typeof(Microsoft.UI.Xaml.Controls.TextBox), textBoxStyle);

        }

#endif

    }

Actual output Image

Expected output: Image

Note: Previously the issue occurred in v8.0.90. This has been resolved in the latest release, version 8.0.92. But it again is not working in .NET 9.0.0-rc.1.24431.7 and 9.0.0-rc.2.24503.2.

Steps to Reproduce

  1. Run the attached sample.
  2. Notice editor width issue.

Link to public reproduction project repository

https://github.com/Lakshminatarajan/MAUIEditorIssue

Version with bug

9.0.0-rc.2.24503.2

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.92 SR9.2

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No.

Relevant log output

No response

jaosnz-rep commented 3 weeks ago

I can repro this issue at Windows platform on the latest 17.12.0 preview 5(9.0.0-rc.2.24503.2), but it used to work in 8.0.92.