【问题标题】:Not able to access StaticResource in Xamarin Forms from app.xaml无法从 app.xaml 访问 Xamarin 表单中的 StaticResource
【发布时间】:2017-12-08 16:07:05
【问题描述】:

我无法访问在 app.xaml 中创建的静态资源。 它是我的 app.xaml 代码

<Application.Resources>
    <ResourceDictionary>
      <Color x:Key="AppDefaultColor">#07bab7</Color>
      <Color x:Key="PageDefaultColor">#f0f0f0</Color>
    </ResourceDictionary>
  </Application.Resources>

当我尝试在我的页面中将其用作静态资源时,它会出错。 它是我用来从 app.xaml 访问静态资源的页面代码

<Label Text="Test"  TextColor="{StaticResource AppDefaultColor}"  />

【问题讨论】:

    标签: xaml xamarin


    【解决方案1】:

    请检查您的 app.xaml.cs 类是否调用了 InitializeComponent() 方法。在创建 App.xaml 和后面的关联代码时需要的 App 构造函数中。

    请看图

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-01
      • 2018-08-19
      • 2017-11-12
      • 1970-01-01
      • 2021-01-09
      • 1970-01-01
      相关资源
      最近更新 更多