Search code examples
uno-platform

Uno Material Card Formatting


I am using the Uno Material Card in my app. Recently there was a change to Uno.Material in the way it was initialized. I implemented that- with some help from @sbilogan in this response: Uno Material Initialization. However- the text in my cards no longer have the formatting. I tried adding back in the template to format the text- but it did not work. I am guessing something is being changed here- but not sure how to proceed. Here is my sample code and screenshots:

<material:Card x:Name="appInfoCard" HeaderContent="App Information"
               SubHeaderContent="Tap to see more"
               SupportingContent="App: "            
               Style="{ThemeResource MaterialOutlinedCardStyle}"
               MediaContent="Example"        
               Foreground="{ThemeResource SubPageTextColor}"
               Background="{ThemeResource cardBackground}">
            <material:Card.MediaContentTemplate>
                <DataTemplate>
                    <StackPanel Padding="10">
                            <Omitted for clarity>
                    </StackPanel>
                </DataTemplate>
            </material:Card.MediaContentTemplate>
            </material:Card>

The code with the full template(I had to use this at one point- but the a change was merged into Uno Material so I did not have to use it anymore)

<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>

The top image was made with Uno Material build 774. The bottom was with 782.
Image- before and after


Solution

  • It turns out that in my MaterialColorOverridePallette.xaml- I had the following set: Green Green

    For some reason- it did not interfere with the formatting before 774. After 774- it removes the formatting from these categories for some reason. Removing them caused them to work as expected in 802 and beyond. Hopefully this helps someone else.