Skip to content

Add Windows Support to SelectableLabel Control#8

Merged
0xc3u merged 3 commits into
mainfrom
copilot/fix-7
Aug 6, 2025
Merged

Add Windows Support to SelectableLabel Control#8
0xc3u merged 3 commits into
mainfrom
copilot/fix-7

Conversation

Copilot AI commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

This PR adds comprehensive Windows support to the Indiko.Maui.Controls.SelectableLabel library, enabling the control to work seamlessly across all major MAUI platforms.

What's Added

Windows Platform Handler

  • Implemented a complete Windows handler using WinUI 3's RichTextBlock control
  • Enables text selection with IsTextSelectionEnabled = true
  • Provides full feature parity with existing Android, iOS, and MacCatalyst implementations

Target Framework Support

  • Added net8.0-windows10.0.19041.0 target framework to the library
  • Updated sample project to include Windows target for testing
  • Set minimum Windows version to 10.0.17763.0 (Windows 10 version 1809)

Complete Feature Implementation

The Windows handler supports all existing SelectableLabel features:

  • Text Properties: Text, TextColor, FontAttributes, FontSize, FontFamily
  • Layout: LineBreakMode, LineHeight, MaxLines, text alignment
  • Formatting: TextDecorations (underline, strikethrough), TextTransform, CharacterSpacing
  • Rich Text: FormattedText with multiple spans and individual styling
  • Background: BackgroundColor support

Platform-Specific Optimizations

  • Uses RichTextBlock for optimal text selection experience on Windows
  • Properly maps MAUI properties to WinUI equivalents (e.g., TextAlignment, TextWrapping)
  • Handles character spacing conversion from em units to WinUI format
  • Implements text truncation using TextTrimming for ellipsis behavior

Bug Fixes

Also fixed existing issues in the core SelectableLabel class:

  • Corrected MaxLinesProperty BindableProperty declaration (was incorrectly using nameof(LineHeight))
  • Fixed TextTransformProperty BindableProperty declaration (was incorrectly using nameof(TextDecorations))

Developer Experience

  • No breaking changes - existing XAML and C# code works unchanged
  • Automatic platform detection through conditional compilation
  • Consistent API across all platforms
  • Updated documentation to reflect Windows support

Usage Example

<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-windows10.0.19041.0</TargetFrameworks>
builder.UseSelectableLabel(); // Automatically registers Windows handler
<idk:SelectableLabel
    Text="This text is now selectable on Windows too!"
    TextColor="Blue"
    FontSize="18" />

The implementation follows the established patterns from other platform handlers and ensures consistent behavior across all supported platforms.

Fixes #7.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits August 6, 2025 09:40
Co-authored-by: 0xc3u <45848928+0xc3u@users.noreply.github.com>
Co-authored-by: 0xc3u <45848928+0xc3u@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Windows Support Add Windows Support to SelectableLabel Control Aug 6, 2025
Copilot AI requested a review from 0xc3u August 6, 2025 09:44

@0xc3u 0xc3u left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use .net9

net9.0-android;net9.0-ios;net9.0-windows10.0.19041.0

instead of net8.

@0xc3u 0xc3u marked this pull request as ready for review August 6, 2025 09:50
@0xc3u 0xc3u merged commit cd47d8d into main Aug 6, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Windows Support

2 participants