下面是我的代码:
grid.Children.Add(new Label { Text = "00", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, TextColor = " {DynamicResource PageBackgroundColor}" });
但它不接受动态资源设置的格式。
vltsax251#
发生这种情况是因为您使用了错误的语法,请尝试以下操作:
TextColor = (Color) App.Current.Resources["PageBackgroundColor"];
如果动态资源在运行时不断变化,请执行以下操作:
yourLabel.SetDynamicResource (VisualElement.TextColorProperty, "PageBackgroundColor");
如有疑问,请回复
dy2hfwbg2#
yourLabel.SetDynamicResource (Label.TextColorProperty, "PageBackgroundColor");
2条答案
按热度按时间vltsax251#
发生这种情况是因为您使用了错误的语法,请尝试以下操作:
如果动态资源在运行时不断变化,请执行以下操作:
如有疑问,请回复
dy2hfwbg2#