WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

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

Open wherewhere opened this issue 10 months ago • 2 comments

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?

  • [ ] This bug can be reproduced in the 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

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [X] Windows 10 22H2 (Build 19045)
  • [ ] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • [X] Windows 10, version 1809 (Build 17763)
  • [ ] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [X] Windows 11, version 2209 (Build 22621)
  • [ ] Other (specify)

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

  • Microsoft.Toolkit.Uwp.Notifications (7.1.3)

Additional context

No response

Help us help you

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

wherewhere avatar Sep 05 '23 15:09 wherewhere