简体   繁体   English

Uno平台材料卡使用Pathicon

[英]Uno Platform Material Card Use Pathicon

I am using a Material Card on my Uno based app.我在基于 Uno 的应用程序上使用了 Material Card。 It works great- except I am trying to add a Pathicon for MediaContent and am having trouble getting it to work.它工作得很好——除了我试图为 MediaContent 添加一个 Pathicon 并且无法让它工作。 I tried overriding the Image source in the template- but that did not work- I may not have done that right.我尝试覆盖模板中的图像源——但这没有用——我可能没有做对。 Essentially I want a Pathicon where the.png or jpg would go.本质上我想要一个Pathicon,其中.png或jpg会是go。 Any suggestions on how to accomplish this would be appreciated.任何有关如何实现此目的的建议将不胜感激。

<material:Card HeaderContent="Outlined card"
               SubHeaderContent="With title and subtitle only"
               MediaContent="" 
               Style="{StaticResource MaterialOutlinedCardStyle}"
               PointerExited="eventPageClick">
            <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.MediaContentTemplate>
                <DataTemplate>
                    <Image Source="{Binding}"
                        Stretch="Uniform"
                        MaxHeight="194" />
                </DataTemplate>
            </material:Card.MediaContentTemplate>
        </material:Card>

Great question!好问题!

Using the MediaContentTemplate , you should be able to place anything that you want in the DataTemplate , including PathIcon s.使用MediaContentTemplate ,您应该能够在DataTemplate中放置您想要的任何东西,包括PathIcon Only thing is that the MediaContentTemplate will only be loaded if the MediaContent property is not null or an empty string.只有当MediaContent属性不是null或空字符串时才会加载MediaContentTemplate So I would do something like setting the the Path Data string to MediaContent and then use a Binding in the MediaContentTemplate to the PathIcon 's Data property, like so:所以我会做一些事情,比如将 Path Data 字符串设置为MediaContent ,然后在MediaContentTemplate中使用BindingPathIconData属性,如下所示:

<material:Card HeaderContent="Outlined card"
               SubHeaderContent="With title and subtitle only"
               MediaContent="PASTE PATH DATA HERE" 
               Style="{StaticResource MaterialOutlinedCardStyle}"
               PointerExited="eventPageClick">
    <controls:Card.MediaContentTemplate>
        <DataTemplate>
            <PathIcon Data="{Binding}"/>
        </DataTemplate>
    </controls:Card.MediaContentTemplate>
    ...
</material:Card>

Thank you sbilogan.谢谢你。 You gave me the key to getting it working.你给了我让它工作的钥匙。 They key was the text cant be empty for Media Content.他们的关键是媒体内容的文本不能为空。 It turns out I can put any text there and then add the Pathicon like below and that works.事实证明,我可以将任何文本放在那里,然后像下面那样添加 Pathicon,这样就可以了。 Thank you so much for your help!非常感谢你的帮助!

<material:Card HeaderContent="Outlined card3"
               SubHeaderContent="With title and subtitle only"
               Style="{StaticResource MaterialOutlinedCardStyle}"
               MediaContent="Example"        
               PointerExited="eventPageClick">
            <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.MediaContentTemplate>
                <DataTemplate>
                    <PathIcon HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Data="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>
                 </DataTemplate>
            </material:Card.MediaContentTemplate>
        </material:Card>

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

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