xamarin Source vs MergeWith如何使用它

时间:2018-10-09 09:22:09

标签: xamarin.forms

有关ResourceDictionary的快速问题。

在代码中,我曾经有这行代码

 Application.Current.Resources.MergedWith = typeof(myResourceDictionary);

显然“ MergeWith”已过时!我们应该使用“来源”。

   Application.Current.Resources.Source = new Uri("myResourceDictionary.xaml");

但是我在上面所做的工作不起作用。

我应该如何在代码中使用源代码?

谢谢

1 个答案:

答案 0 :(得分:0)

如果您使用XAML,则可以这样设置:

 <ContentPage.Resources>

        <!-- Add more resources here -->

        <ResourceDictionary Source="MyResourceDictionary.xaml" />

        <!-- Add more resources here -->

    </ContentPage.Resources>