.net core UWP磁贴不显示svg图像
下面是windows 10“开始”菜单上的平铺代码,显示了我使用创建的“.png”图像。但是相同的代码没有显示我使用创建的类似.net core UWP磁贴不显示svg图像,.net-core,uwp,windows-community-toolkit,msix,.net Core,Uwp,Windows Community Toolkit,Msix,下面是windows 10“开始”菜单上的平铺代码,显示了我使用创建的“.png”图像。但是相同的代码没有显示我使用创建的类似.svg图像(在磁贴中) 问题:为什么相同的代码不适用于.svg图像,而适用于.png图像?我们如何使它也适用于.svg图像 带有.png文件的平铺显示的开始菜单快照: public void TileTest() { // Construct the tile content TileContent content = new TileContent()
.svg
图像(在磁贴中)
问题:为什么相同的代码不适用于.svg
图像,而适用于.png
图像?我们如何使它也适用于.svg
图像
带有.png文件的平铺显示的开始菜单快照:
public void TileTest()
{
// Construct the tile content
TileContent content = new TileContent()
{
Visual = new TileVisual()
{
TileWide = new TileBinding()
{
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveGroup()
{
Children =
{
new AdaptiveSubgroup()
{
HintWeight = 2,
Children =
{
new AdaptiveImage()
{
//NOTE: if I replace Test.png with Test.svg image, it
//does not show up
Source = "Images/MyImages/Test.png",
HintRemoveMargin = true
}
}
}
}
},
}
}
}
}
};
TileNotification notification = new TileNotification(content.GetXml());
TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="drawing.svg">
<defs
id="defs2">
<rect
x="60.47619"
y="99.785714"
width="74.839286"
height="34.017857"
id="rect24" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="400"
inkscape:cy="560"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1267"
inkscape:window-height="728"
inkscape:window-x="83"
inkscape:window-y="0"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
id="text22"
style="font-weight:bold;font-size:10.5833px;line-height:1.25;font-family:'Bookman Old Style';-inkscape-font-specification:'Bookman Old Style Bold';text-align:center;white-space:pre;shape-inside:url(#rect24)"
x="0"
y="0"><tspan
x="85.936012"
y="109.17887"><tspan
style="text-align:center;text-anchor:middle">Test</tspan></tspan></text>
</g>
</svg>
代码:
public void TileTest()
{
// Construct the tile content
TileContent content = new TileContent()
{
Visual = new TileVisual()
{
TileWide = new TileBinding()
{
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveGroup()
{
Children =
{
new AdaptiveSubgroup()
{
HintWeight = 2,
Children =
{
new AdaptiveImage()
{
//NOTE: if I replace Test.png with Test.svg image, it
//does not show up
Source = "Images/MyImages/Test.png",
HintRemoveMargin = true
}
}
}
}
},
}
}
}
}
};
TileNotification notification = new TileNotification(content.GetXml());
TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="drawing.svg">
<defs
id="defs2">
<rect
x="60.47619"
y="99.785714"
width="74.839286"
height="34.017857"
id="rect24" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="400"
inkscape:cy="560"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1267"
inkscape:window-height="728"
inkscape:window-x="83"
inkscape:window-y="0"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
id="text22"
style="font-weight:bold;font-size:10.5833px;line-height:1.25;font-family:'Bookman Old Style';-inkscape-font-specification:'Bookman Old Style Bold';text-align:center;white-space:pre;shape-inside:url(#rect24)"
x="0"
y="0"><tspan
x="85.936012"
y="109.17887"><tspan
style="text-align:center;text-anchor:middle">Test</tspan></tspan></text>
</g>
</svg>
备注:这可能无关紧要,但只是以防万一:我正在使用一个调用UWP/WinRT API的应用程序-使用VS2019-ver 16.9
和Windows 10 Pro-ver 2004
上的.NET5
。
以下是我在上述代码上尝试的.png
和.svg
图像。svg未显示在磁贴中:
Test.png:
public void TileTest()
{
// Construct the tile content
TileContent content = new TileContent()
{
Visual = new TileVisual()
{
TileWide = new TileBinding()
{
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveGroup()
{
Children =
{
new AdaptiveSubgroup()
{
HintWeight = 2,
Children =
{
new AdaptiveImage()
{
//NOTE: if I replace Test.png with Test.svg image, it
//does not show up
Source = "Images/MyImages/Test.png",
HintRemoveMargin = true
}
}
}
}
},
}
}
}
}
};
TileNotification notification = new TileNotification(content.GetXml());
TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="drawing.svg">
<defs
id="defs2">
<rect
x="60.47619"
y="99.785714"
width="74.839286"
height="34.017857"
id="rect24" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="400"
inkscape:cy="560"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1267"
inkscape:window-height="728"
inkscape:window-x="83"
inkscape:window-y="0"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
id="text22"
style="font-weight:bold;font-size:10.5833px;line-height:1.25;font-family:'Bookman Old Style';-inkscape-font-specification:'Bookman Old Style Bold';text-align:center;white-space:pre;shape-inside:url(#rect24)"
x="0"
y="0"><tspan
x="85.936012"
y="109.17887"><tspan
style="text-align:center;text-anchor:middle">Test</tspan></tspan></text>
</g>
</svg>
测试.Svg:
public void TileTest()
{
// Construct the tile content
TileContent content = new TileContent()
{
Visual = new TileVisual()
{
TileWide = new TileBinding()
{
Content = new TileBindingContentAdaptive()
{
Children =
{
new AdaptiveGroup()
{
Children =
{
new AdaptiveSubgroup()
{
HintWeight = 2,
Children =
{
new AdaptiveImage()
{
//NOTE: if I replace Test.png with Test.svg image, it
//does not show up
Source = "Images/MyImages/Test.png",
HintRemoveMargin = true
}
}
}
}
},
}
}
}
}
};
TileNotification notification = new TileNotification(content.GetXml());
TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="drawing.svg">
<defs
id="defs2">
<rect
x="60.47619"
y="99.785714"
width="74.839286"
height="34.017857"
id="rect24" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="400"
inkscape:cy="560"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1267"
inkscape:window-height="728"
inkscape:window-x="83"
inkscape:window-y="0"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
id="text22"
style="font-weight:bold;font-size:10.5833px;line-height:1.25;font-family:'Bookman Old Style';-inkscape-font-specification:'Bookman Old Style Bold';text-align:center;white-space:pre;shape-inside:url(#rect24)"
x="0"
y="0"><tspan
x="85.936012"
y="109.17887"><tspan
style="text-align:center;text-anchor:middle">Test</tspan></tspan></text>
</g>
</svg>
image/svg+xml
试验
我们经常使用UWP应用程序图标生成器制作应用程序的可视化资产,当您选择图像时,您会发现svg类型不在支持列表中。@NicoZhu MSFT如果您有任何解决方案/建议等,我还有另一个问题发布。-谢谢。