Describe the bug
When creating Live tile content via TileContentBuilder, I always get NullReferenceException when setting the text on Wide sized tile.
❗ This only happens when trying to create Wide Live tile alone ❗ When Medium tile is present, it's all working.
Steps to Reproduce
Create sample Live tile content with TileContentBuilder, but only for Wide tile size, like in the sample code below and try to run it:
var builder = new TileContentBuilder();
builder.AddTile(TileSize.Wide)
.SetTextStacking(TileTextStacking.Top)
.AddText("Header", hintStyle: AdaptiveTextStyle.Base)
.AddText("Subtitle", hintStyle: AdaptiveTextStyle.CaptionSubtle)
.SetBranding(TileBranding.NameAndLogo);
TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(builder.Content.GetXml()));
Expected behavior
Screenshots
Bug in code
According to NullReferenceException, the core issue was thrown from this method:
TileContentBuilder.AddAdaptiveTileVisualChild(ITileBindingContentAdaptiveChild child, TileSize size)
After inspecting the code of that method in this repository, I think I found what's causing it.
It's this line in the method, it's incorrectly getting the content from MediumTile instead of WideTile. As MediumTile is not set in my case, the exception is thrown.
if (size.HasFlag(TileSize.Wide) && WideTile != null && GetAdaptiveTileContent(--> MediumTile <--) != null)
{
GetAdaptiveTileContent(WideTile).Children.Add(child);
}
Environment
NuGet Package(s): Microsoft.Toolkit.Uwp.Notifications
Package Version(s): 7.0.1
Windows 10 Build Number:
App min and target version:
Device form factor:
Visual Studio
Additional context
Describe the bug
When creating Live tile content via
TileContentBuilder, I always getNullReferenceExceptionwhen setting the text on Wide sized tile.❗ This only happens when trying to create Wide Live tile alone ❗ When Medium tile is present, it's all working.
No, it's a bug on the current version as well as in the current repository code.
Steps to Reproduce
No, because in the sample app you're creating Live tile content for all sizes: Medium, Wide, and Large, this only happens when you want to set solely Wide Live tile content.
Create sample Live tile content with TileContentBuilder, but only for Wide tile size, like in the sample code below and try to run it:
Expected behavior
Screenshots
Bug in code
According to
NullReferenceException, the core issue was thrown from this method:TileContentBuilder.AddAdaptiveTileVisualChild(ITileBindingContentAdaptiveChild child, TileSize size)After inspecting the code of that method in this repository, I think I found what's causing it.
It's this line in the method, it's incorrectly getting the content from
MediumTileinstead ofWideTile. AsMediumTileis not set in my case, the exception is thrown.Environment
NuGet Package(s): Microsoft.Toolkit.Uwp.Notifications
Package Version(s): 7.0.1
Windows 10 Build Number:
App min and target version:
Device form factor:
Visual Studio
Additional context