简体   繁体   English

Uno平台材料卡

[英]Uno Platform Material Card

I am trying to use the card from the Material design that Uno has added.我正在尝试使用 Uno 添加的 Material Design 中的卡片。 However- when I followed the example- the card would not appear.但是-当我按照示例进行操作时-卡片不会出现。 I am using the bottomNavigationBar from Material elsewhere in the app and it is working fine.我在应用程序的其他地方使用 Material 的 bottomNavigationBar,它工作正常。 As a note- I saw one example with Header and one with HeaderContent.作为说明 - 我看到了一个 Header 的例子和一个 HeaderContent 的例子。 I have tried both and neither worked.我都尝试过,但都没有奏效。 Nothing is displayed at all- IOS or Android.什么都没有显示 - IOS 或 Android。 What am I missing?我错过了什么? Thanks for your help!谢谢你的帮助!

<Page
    x:Class="sampleApp.Shared.Views.appCardPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:sampleApp.Shared.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:material="using:Uno.Material.Controls"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <StackPanel Orientation="Vertical" Background="{StaticResource SubPageBackground}" >

        <material:Card HeaderContent="Outlined card"
           SubHeaderContent="With title and subitle"
           Style="{StaticResource MaterialOutlinedCardStyle}" />
        
    </StackPanel>
</Page>

Try like this像这样试试

<material:Card HeaderContent="Outlined card"
               SubHeaderContent="With title and subtitle only"
               Style="{StaticResource MaterialOutlinedCardStyle}">
   <material:Card.HeaderContentTemplate>
      <DataTemplate>
         <TextBlock Text="{Binding}"
                    Margin="16,14,16,0"
                    Style="{ThemeResource MaterialHeadline6}" />
      </DataTemplate>
   </material:Card.HeaderContentTemplate>
   <material:Card.SubHeaderContentTemplate>
      <DataTemplate>
         <TextBlock Text="{Binding}"
                    Margin="16,0,16,14"
                    Style="{ThemeResource MaterialBody2}" />
      </DataTemplate>
   </material:Card.SubHeaderContentTemplate>
</material:Card>

It seems HeaderContentTemplate and SubHeaderContentTemplate don't have a default value in the MaterialOutlinedCardStyle style, that could be improved.似乎HeaderContentTemplateSubHeaderContentTemplateMaterialOutlinedCardStyle样式中没有默认值,可以改进。

So I did some further testing- and it turns out in my app.xaml.cs I was not initializing the material theme correctly.所以我做了一些进一步的测试——结果在我的 app.xaml.cs 中我没有正确初始化材质主题。 I changed it to what is in the example found here:Uno Material Documentation我将其更改为此处找到的示例中的内容:Uno Material Documentation

In section 3. What was really interesting is the bottomNavigationBar I use from Material worked in spite of all of this.在第 3 节中。真正有趣的是我在 Material 中使用的 bottomNavigationBar,尽管如此。 Hopefully this will help someone else that has a similar issue.希望这将有助于其他有类似问题的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM