问题描述
对于我看到的页面
RemoveDynamicResource(BackgroundColorProperty);
this.DynamicResource(BackgroundColorProperty,nameof(BaseTheme.GitTrendsimagebackgroundColor));
所以我想知道,为什么需要先删除资源?下一行的设置是否不会覆盖并删除它?
解决方法
下一行的设置是否不会覆盖并删除它
Element.RemoveDynamicResource 方法是删除之前设置的动态资源。更新 dynamicResource 时不需要调用该方法。并且没有 Element.DynamicResource
方法或它已被弃用,请尝试改用 Element.SetDynamicResource
。
this.SetDynamicResource(ContentPage.StyleProperty,"theCustomStyle");