CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.9k stars 1.37k forks source link

The "id" attribute is missing on AdaptiveText which is needed for lock screen notification #4933

Open wherewhere opened 1 year ago

wherewhere commented 1 year ago

Describe the bug

The way to show notification on lock screen is to set the id of the text in wide tile, such as

<binding template="TileWide">
    <text id="1">Line1</text>
    <text id="2">Line2</text>
    <text id="3">Line3</text>
</binding>

Which using TileContent is

TileWide = new TileBinding
{
    Content = new TileBindingContentAdaptive
    {
        Children =
        {
            new AdaptiveGroup
            {
                Children =
                {
                    new AdaptiveText
                    {
                        Id = 1,
                        Text = "Line1"
                    },
                    new AdaptiveText
                    {
                        Id = 2,
                        Text = "Line2"
                    },
                    new AdaptiveText
                    {
                        Id = 3,
                        Text = "Line3"
                    }
                }
            }
        }
    }
}

But the Id property is missing on AdaptiveText. I found that the Id property is exist in Element_AdaptiveText. So I change the ConvertToElement method and it works.

internal Element_AdaptiveText ConvertToElement()
{
    Element_AdaptiveText answer = new Element_AdaptiveText
    {
        Id = Id,
        Lang = Language,
        Style = HintStyle,
        Wrap = HintWrap,
        MaxLines = HintMaxLines,
        MinLines = HintMinLines,
        Align = HintAlign
    };

#if WINRT 
    answer.Text = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveTextBindableProperty.Text, Text); 
#else 
    answer.Text = Text?.ToXmlString(); 
#endif 

    return answer;
}

Regression

No response

Reproducible in sample app?

Steps to reproduce

1. Write a tile notification.
2. Try to show it on lock screen.
3. There is no way to show but to write xml by my own...

Expected behavior

It should appeal on lock screen easily.

Screenshots

Cache_-5e2ff88e5797a1f0.jpg

Windows Build Number

Other Windows Build number

No response

App minimum and target SDK version

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

17.8.0 Preview 1.0

Device form factor

Desktop

Nuget packages

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item.

ghost commented 1 year ago

Hello wherewhere, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

wherewhere commented 1 year ago

@michael-hawker Lock Screen notification is still support on Windows 11. So I think this issue should be fixed. IMG_20230909_232344.jpg