UWP 平铺图像拉伸和填充
UWP Tile Image Stretch and Fill
我正在尝试实现一个缩略图完全覆盖图块的图块。但还有一定余量。我怎样才能删除它并使其拉伸并填满整个图块?
另一个问题是,除了图像问题,在TileMedium
中,文字没有显示出来。我期待它出现在左下角。我该如何解决?
我的最后一个问题是,虽然我已经在代码中实现了它,但是当我右键单击图块以调整其大小时,TileLarge
并没有作为一个选项出现。
这是代码:
public static void UpdateTile(Music music)
{
string uri = Thumbnail.Path;
var tileContent = new TileContent()
{
Visual = new TileVisual()
{
TileMedium = new TileBinding()
{
Branding = TileBranding.None,
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveImage() { Source = uri },
}
}
},
TileWide = new TileBinding()
{
Branding = TileBranding.None,
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveImage()
{
Source = uri
},
new AdaptiveText()
{
Text = music.Name,
HintStyle = AdaptiveTextStyle.Title
}
}
}
},
TileLarge = new TileBinding()
{
Branding = TileBranding.None,
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveImage()
{
Source = uri
},
new AdaptiveGroup()
{
Children =
{
new AdaptiveSubgroup()
{
Children =
{
new AdaptiveText()
{
Text = music.Name,
HintStyle = AdaptiveTextStyle.Caption
},
new AdaptiveText()
{
Text = music.Artist,
HintStyle = AdaptiveTextStyle.CaptionSubtle
}
}
}
}
},
}
}
}
}
};
// Create the tile notification
var tileNotification = new TileNotification(tileContent.GetXml());
// And send the notification to the primary tile
tileUpdater.Update(tileNotification);
}
}
抱歉问了这么多问题。提前致谢!
Q1:Image problem
如果要填充图块,可以将图像设置为 BackgroundImage 而不是 AdaptiveImage。
Q2:Show text at the left bottom in TileMedium.
您可以在TileMedium.In这种情况下设置Displayname和Branding,文本将出现在左下角。
TileMedium = new TileBinding()
{
DisplayName = music.Name,
Branding = TileBranding.Name,
Content = new TileBindingContentAdaptive()
{
BackgroundImage = new TileBackgroundImage()
{
Source = uri
},
Children =
{
......
}
}
},
Q3:TileLarge
转到 Package.appxmanifest->视觉资产->大图块。Select 显示设置中的大图块选项。
我正在尝试实现一个缩略图完全覆盖图块的图块。但还有一定余量。我怎样才能删除它并使其拉伸并填满整个图块?
另一个问题是,除了图像问题,在TileMedium
中,文字没有显示出来。我期待它出现在左下角。我该如何解决?
我的最后一个问题是,虽然我已经在代码中实现了它,但是当我右键单击图块以调整其大小时,TileLarge
并没有作为一个选项出现。
这是代码:
public static void UpdateTile(Music music)
{
string uri = Thumbnail.Path;
var tileContent = new TileContent()
{
Visual = new TileVisual()
{
TileMedium = new TileBinding()
{
Branding = TileBranding.None,
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveImage() { Source = uri },
}
}
},
TileWide = new TileBinding()
{
Branding = TileBranding.None,
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveImage()
{
Source = uri
},
new AdaptiveText()
{
Text = music.Name,
HintStyle = AdaptiveTextStyle.Title
}
}
}
},
TileLarge = new TileBinding()
{
Branding = TileBranding.None,
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveImage()
{
Source = uri
},
new AdaptiveGroup()
{
Children =
{
new AdaptiveSubgroup()
{
Children =
{
new AdaptiveText()
{
Text = music.Name,
HintStyle = AdaptiveTextStyle.Caption
},
new AdaptiveText()
{
Text = music.Artist,
HintStyle = AdaptiveTextStyle.CaptionSubtle
}
}
}
}
},
}
}
}
}
};
// Create the tile notification
var tileNotification = new TileNotification(tileContent.GetXml());
// And send the notification to the primary tile
tileUpdater.Update(tileNotification);
}
}
抱歉问了这么多问题。提前致谢!
Q1:Image problem
如果要填充图块,可以将图像设置为 BackgroundImage 而不是 AdaptiveImage。
Q2:Show text at the left bottom in TileMedium.
您可以在TileMedium.In这种情况下设置Displayname和Branding,文本将出现在左下角。
TileMedium = new TileBinding()
{
DisplayName = music.Name,
Branding = TileBranding.Name,
Content = new TileBindingContentAdaptive()
{
BackgroundImage = new TileBackgroundImage()
{
Source = uri
},
Children =
{
......
}
}
},
Q3:TileLarge
转到 Package.appxmanifest->视觉资产->大图块。Select 显示设置中的大图块选项。