Kuldeep Kumawat
Kuldeep Kumawat

Reputation: 33

Not able to access StaticResource in Xamarin Forms from app.xaml

I am not able to access static resources that created in app.xaml. its my app.xaml code

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

when i try to use this in my page as static resource it gives error. its my page code which i used to access static resource from app.xaml

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

Upvotes: 3

Views: 807

Answers (1)

Ashok Kumawat
Ashok Kumawat

Reputation: 643

Please Check that your app.xaml.cs class call InitializeComponent() method. In the App constructor which is required when creating the App.xaml and associated code behind.

Please look into picture

app.xaml.cs

Upvotes: 2

Related Questions