microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.28k stars 675 forks source link

RichEditBox theme bug #5893

Closed HppZ closed 2 years ago

HppZ commented 3 years ago

before switch theme: image after: image switch back to light: image

the Text color lost.

HppZ commented 3 years ago

https://github.com/HppZ/RichEditBoxThemeBug

HppZ commented 3 years ago

@codendone

StephenLPeters commented 3 years ago

@HppZ is this a Winui3 or Winui2 (or both) issue?

HppZ commented 3 years ago

UWP


发件人: Stephen L Peters @.> 发送时间: Friday, September 17, 2021 8:24:03 AM 收件人: microsoft/microsoft-ui-xaml @.> 抄送: HppZ @.>; Mention @.> 主题: Re: [microsoft/microsoft-ui-xaml] RichEditBox theme bug (#5893)

@HppZhttps://github.com/HppZ is this a Winui3 or Winui2 (or both) issue?

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/microsoft/microsoft-ui-xaml/issues/5893#issuecomment-921353557, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC5XNDSGBK7CWD3GN2GZMU3UCKDCHANCNFSM5EEZVRUQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

HppZ commented 3 years ago

system xaml control


发件人: Hao Xiaoyan @.> 发送时间: Friday, September 17, 2021 9:32:31 AM 收件人: microsoft/microsoft-ui-xaml @.>; microsoft/microsoft-ui-xaml @.> 抄送: Mention @.> 主题: Re: [microsoft/microsoft-ui-xaml] RichEditBox theme bug (#5893)

UWP


发件人: Stephen L Peters @.> 发送时间: Friday, September 17, 2021 8:24:03 AM 收件人: microsoft/microsoft-ui-xaml @.> 抄送: HppZ @.>; Mention @.> 主题: Re: [microsoft/microsoft-ui-xaml] RichEditBox theme bug (#5893)

@HppZhttps://github.com/HppZ is this a Winui3 or Winui2 (or both) issue?

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/microsoft/microsoft-ui-xaml/issues/5893#issuecomment-921353557, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC5XNDSGBK7CWD3GN2GZMU3UCKDCHANCNFSM5EEZVRUQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

aqibbanday commented 3 years ago

Hi The issue is not with the control but the sample you have shared.

private void RichEdit_Loaded(object sender, RoutedEventArgs e)
        {
            var range = this.Document.GetRange(int.MaxValue, int.MaxValue);
            //range.CharacterFormat.ForegroundColor = Colors.Aqua;
            range.SetText(TextSetOptions.None, "@123");
        }

You are changing the Foreground color on Load.

aqibbanday commented 3 years ago

@msft-github-bot Close the issue.

HppZ commented 3 years ago

why you comment out //range.CharacterFormat.ForegroundColor = Colors.Aqua; ?

aqibbanday commented 3 years ago

This is causing the issue, on Load you are setting the foreground color to Aqua.

HppZ commented 3 years ago

I need to set the Color.

HppZ commented 3 years ago

I want to keep the Color no matter what the RequestedTheme is.

aqibbanday commented 3 years ago

Set the color in xaml. <local:RichEdit Width="100" Height="50" Margin="0,100,0,0" Foreground="Aqua" />

HppZ commented 3 years ago

Set the color in xaml. <local:RichEdit Width="100" Height="50" Margin="0,100,0,0" Foreground="Aqua" />

I want to set different Color on different TextRange in RichEditBox, so this is not enough.

aqibbanday commented 3 years ago

Can you share an example of the result you want.

HppZ commented 3 years ago

image

HppZ commented 3 years ago

in dark theme, the Color lost. image

HppZ commented 3 years ago

do you think this is bug? @aqibbanday

aqibbanday commented 3 years ago

The Foreground property of RTB is overriding the ForegroundColor of CharacterFormat

HppZ commented 3 years ago

The Foreground property of RTB is overriding the ForegroundColor of CharacterFormat

how to solve it?

HppZ commented 3 years ago

i think this works Foreground="{x:Null}"

HppZ commented 3 years ago

The Foreground property of RTB is overriding the ForegroundColor of CharacterFormat

but why RTB has this behavior?

aqibbanday commented 3 years ago

I have fixed this issue in my repo, i can merge the changes, if you give me the access.

HppZ commented 3 years ago

I have fixed this issue in my repo, i can merge the changes, if you give me the access.

invited

aqibbanday commented 3 years ago

The Foreground property of RTB is overriding the ForegroundColor of CharacterFormat

but why RTB has this behavior?

Foreground is linked to Theme changes and ForegroundColor property gets its color from Foreground property, that's the behaviour.

aqibbanday commented 3 years ago

Check the comit , i have also addressed the issue with range color.

HppZ commented 3 years ago

thanks. so the point is: Foreground="{x:Null}", right?

aqibbanday commented 3 years ago

Yes.

HppZ commented 3 years ago

Thanks.

HppZ commented 3 years ago

I don't think this is a good design, so reopen this issue.

chrisglein commented 2 years ago

I don't think this is a good design, so reopen this issue.

There is lots of back and forth on this issue. It sounds like it resulted in an bug in the provided sample code itself, which has since been patched. I'm not sure which part is being pointed to as not a good design. This issue also isn't following the standard issue template, so we're missing some issue on context. I'm going to re-close this issue. Please open a new issue with a proposal for the design that you think is appropriate (that describes the problem in context and fills out the issue template).