如何在xaml中使用静态资源?

时间:2018-02-22 09:20:00

标签: c# xaml xamarin.forms

我想把我的StringFormat取出给静态资源。

我试图这样做,但它不起作用

.. xmlns:system="clr-namespace:System;assembly=mscorlib">
    ResourceDictionary>
           <system:String x:Key="MyFormat">'http://www.gravatar.com/avatar/{0}?d=mm&amp;s=150'</system:String>
        </ResourceDictionary>

这里我初始化了我的StringFormat

 <Image.Source>
           <UriImageSource Uri="{Binding EmailHash,StringFormat={StaticResource MyFormat}}}" />
</Image.Source>

1 个答案:

答案 0 :(得分:0)

您的StaticResouce

中似乎有单引号
<system:String x:Key="MyFormat">http://www.gravatar.com/avatar/{0}?d=mm&amp;s=150</system:String>
相关问题