-
Couldn't load subscription status.
- Fork 1.9k
[.NET10] [Enhancement] Display Window Title in bold by default with configurable font attributes #31820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tamilarasan-Paranthaman
wants to merge
7
commits into
dotnet:net10.0
Choose a base branch
from
Tamilarasan-Paranthaman:TitleBar-Title-FontAttributes
base: net10.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[.NET10] [Enhancement] Display Window Title in bold by default with configurable font attributes #31820
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cb32607
Implemented Title FontAttributes
Tamilarasan-Paranthaman 026f347
Added test
Tamilarasan-Paranthaman 25d7d7b
test sample changes
Tamilarasan-Paranthaman 50063d4
Added snapshots
Tamilarasan-Paranthaman 1d2ee36
Merge branch 'TitleBar-Title-FontAttributes' of https://github.com/Ta…
Tamilarasan-Paranthaman e7a1f02
Updated TitleBar.cs
Tamilarasan-Paranthaman 3612317
Added snapshots
Tamilarasan-Paranthaman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 24627, "[Windows] TitleBar Title FontAttributes", PlatformAffected.UWP)] | ||
Tamilarasan-Paranthaman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public class Issue24627 : ContentPage | ||
| { | ||
| TitleBar customTitleBar; | ||
|
|
||
| public Issue24627() | ||
| { | ||
| customTitleBar = new TitleBar | ||
| { | ||
| Title = "MauiApp1", | ||
| Subtitle = "Welcome to .NET MAUI", | ||
| TitleFontAttributes = FontAttributes.Bold, | ||
| HeightRequest = 32 | ||
| }; | ||
|
|
||
| var label = new Label | ||
| { | ||
| Text = "Welcome to .NET MAUI", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| }; | ||
|
|
||
| var button = new Button | ||
Tamilarasan-Paranthaman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| Text = "Set Title FontAttributes to None", | ||
| AutomationId = "ChangeFAButton", | ||
| Command = new Command(() => | ||
| { | ||
| customTitleBar.TitleFontAttributes = FontAttributes.None; | ||
| }), | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center | ||
| }; | ||
|
|
||
| var italicButton = new Button | ||
| { | ||
| Text = "Set Title FontAttributes to Italic", | ||
| AutomationId = "ItalicButton", | ||
| Command = new Command(() => | ||
| { | ||
| customTitleBar.TitleFontAttributes = FontAttributes.Italic; | ||
| }), | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center | ||
| }; | ||
|
|
||
| var verticalStack = new VerticalStackLayout | ||
| { | ||
| Children = | ||
| { | ||
| label, | ||
| button, | ||
| italicButton | ||
| }, | ||
| Spacing = 25, | ||
| Padding = new Thickness(30, 0), | ||
| VerticalOptions = LayoutOptions.Center | ||
| }; | ||
|
|
||
| Content = verticalStack; | ||
| } | ||
|
|
||
| protected override void OnAppearing() | ||
| { | ||
| base.OnAppearing(); | ||
| if (Window is not null) | ||
| { | ||
| Window.TitleBar = customTitleBar; | ||
| } | ||
| else if (Shell.Current?.Window is not null) | ||
| { | ||
| Shell.Current.Window.TitleBar = customTitleBar; | ||
| } | ||
| } | ||
| } | ||
Binary file added
BIN
+19 KB
...TestCases.Mac.Tests/snapshots/mac/ChangeTitleBarTitleFontAttributesToItalic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.9 KB
...s/TestCases.Mac.Tests/snapshots/mac/ChangeTitleBarTitleFontAttributesToNone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.9 KB
...sts/TestCases.Mac.Tests/snapshots/mac/VerifyTitleBarTitleFontAttributesBold.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions
42
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24627.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #if WINDOWS || MACCATALYST // TitleBar is only supported on Windows and MacCatalyst | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue24627 : _IssuesUITest | ||
| { | ||
| public override string Issue => "[Windows] TitleBar Title FontAttributes"; | ||
|
|
||
| public Issue24627(TestDevice device) | ||
| : base(device) | ||
| { } | ||
|
|
||
| [Test, Order(1)] | ||
| [Category(UITestCategories.TitleView)] | ||
| public void VerifyTitleBarTitleFontAttributesBold() | ||
| { | ||
| App.WaitForElement("ChangeFAButton"); | ||
| VerifyScreenshot(includeTitleBar: true); | ||
| } | ||
|
|
||
| [Test, Order(2)] | ||
| [Category(UITestCategories.TitleView)] | ||
| public void ChangeTitleBarTitleFontAttributesToNone() | ||
| { | ||
| App.WaitForElement("ChangeFAButton"); | ||
| App.Tap("ChangeFAButton"); | ||
| VerifyScreenshot(includeTitleBar: true); | ||
| } | ||
|
|
||
| [Test, Order(3)] | ||
| [Category(UITestCategories.TitleView)] | ||
| public void ChangeTitleBarTitleFontAttributesToItalic() | ||
| { | ||
| App.WaitForElement("ItalicButton"); | ||
| App.Tap("ItalicButton"); | ||
| VerifyScreenshot(includeTitleBar: true); | ||
| } | ||
| } | ||
| #endif |
Binary file added
BIN
+11.9 KB
...ses.WinUI.Tests/snapshots/windows/ChangeTitleBarTitleFontAttributesToItalic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.6 KB
...Cases.WinUI.Tests/snapshots/windows/ChangeTitleBarTitleFontAttributesToNone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.7 KB
...stCases.WinUI.Tests/snapshots/windows/VerifyTitleBarTitleFontAttributesBold.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use bold by default? Using None maintain backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I have changed the default value to
FontAttributes.Noneto maintain backward compatibility.