【问题标题】:Is there any way to customize the template of tile?有什么方法可以自定义 tile 的模板吗?
【发布时间】:2016-01-27 07:06:25
【问题描述】:

现在我在我的 UWP 应用程序上实现动态磁贴。

我在 MSDN(https://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx?f=255&MSPPError=-2147217396#versions) 上找到了一些 tile 模板,但 我想更改模板的样式,例如文本大小。 在我的调查中,我没有找到任何方法来更改 tile 的模板。 有什么办法可以改变吗?或者有什么方法可以使用自定义模板?

string tileXmlString = "<tile>"
                             + "<visual>"
                             + "<binding template='TileWide310x150SmallImageAndText04'>"
                             + "<image id='1' src='ms-appx:///images/tile-sdk.png'/>"
                             + "<text id='1'>TEXT ID 1</text>"
                             + "<text id='2'>TEXT ID 2</text>"
                             + "</binding>"
                             + "</visual>"
                             + "</tile>";

提前致谢。

【问题讨论】:

    标签: uwp live-tile


    【解决方案1】:

    您使用的是旧版磁贴模板。您在 UWP 中寻找的是 adaptive tile templates,它是完全可定制的,并且不依赖于像旧版(来自 Windows 8/8.1)这样的固定模板。

    在自适应磁贴模板中,您可以使用 hint-style 属性来自定义您的文本元素,而不是使用映射到固定文本块的 ID。这是上面链接给出的第一个示例:

    <tile>
      <visual>
    
        <binding template="TileMedium">
          ...
        </binding>
    
        <binding template="TileWide">
          <text hint-style="subtitle">Jennifer Parker</text>
          <text hint-style="captionSubtle">Photos from our trip</text>
          <text hint-style="captionSubtle">Check out these awesome photos I took while in New Zealand!</text>
        </binding>
    
        <binding template="TileLarge">
          ...
        </binding>
    
      </visual>
    </tile>
    

    结果:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-13
      • 2013-03-14
      • 1970-01-01
      • 1970-01-01
      • 2017-11-26
      相关资源
      最近更新 更多