I tried to set style to my page using css but i got this exception
Object reference not set to an instance of an object
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XRetailMobile.Views.MainPage"
xmlns:local="clr-namespace:XRetailMobile.Views.ContentViews"
NavigationPage.HasNavigationBar="False">
<ContentPage.Resources>
<StyleSheet Source="/Styles/style.css"/>
</ContentPage.Resources>
<ContentPage.Content>
<Grid HorizontalOptions="Fill" VerticalOptions="Fill">
<local:ProductBackToolbar StyleClass="toolbarStyle" VerticalOptions="Start">
</local:ProductBackToolbar>
</Grid>
</ContentPage.Content>
</ContentPage>
ProductBackToolbar.xaml(contentview)
<ContentView.Content>
<StackLayout HorizontalOptions="Fill" Orientation="Horizontal">
<Image Source="back" HeightRequest="35" VerticalOptions="Center" WidthRequest="35" HorizontalOptions="StartAndExpand"></Image>
<Image Source="share" HeightRequest="35" VerticalOptions="Center" WidthRequest="35" HorizontalOptions="End"></Image>
<Image Source="shoppingbag" HeightRequest="35" WidthRequest="35" VerticalOptions="Center" HorizontalOptions="End"></Image>
</StackLayout>
</ContentView.Content>
style.css Located in Style Folder and its build action is EmbeddedResources
^contentpage {
background-color: greenyellow;
}
.toolbarStyle {
background-color: blue;
margin: 20px;
padding:20px;
}
if i comment margin and padding it's work fine what's the wrong ?