Issue
Hello I got an error while doing login page. I just code Mainpage.xaml file other files are default and I picked "blank" when creating project. My error is:
" System.InvalidOperationException: "The class, property, or method you are attempting to use ("GradientBrush" is part of GradientBrush; to use it, you must opt-in by calling Forms.SetFlags("Brush_Experimental") before calling Forms.Init()."
I just write one file which is Mainpage.xaml
. Does anybody help me how to handle my problem?
<?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="HealthCareApp.MainPage">
<StackLayout>
<StackLayout.Background>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="#48b6a6" Offset="0.1" />
<GradientStop Color="#2b78d4" Offset="1.0" />
</LinearGradientBrush>
</StackLayout.Background>
<StackLayout Padding="0" Margin="10,100,10,0" HorizontalOptions="FillAndExpand" >
<Frame BackgroundColor="Transparent" HeightRequest="500" Padding="0" Margin="0">
<StackLayout>
<StackLayout Margin="10">
<Label Text="SIGN IN" TextColor="White" HorizontalOptions="CenterAndExpand" FontAttributes="Bold" ></Label>
</StackLayout>
<StackLayout Padding="0" Margin="15,10">
<Frame BackgroundColor="Transparent" BorderColor="White" Padding="0" HorizontalOptions="FillAndExpand" CornerRadius="30">
<StackLayout Orientation="Horizontal">
<Frame BackgroundColor="SkyBlue" HeightRequest="40" WidthRequest="40" CornerRadius="30" Padding="0" Margin="5">
<Image Source="https://www.findool.com/images/avatars/avatar.png" Aspect="AspectFill" Margin="0"/>
</Frame>
<Entry Placeholder="Email" TextColor="#666666" FontAttributes="None" HorizontalOptions="FillAndExpand" Margin="0,0,20,0"/>
</StackLayout>
</Frame>
<Frame BackgroundColor="Transparent" BorderColor="White" Margin="0,15,0,0" Padding="0" HorizontalOptions="FillAndExpand" CornerRadius="30">
<StackLayout Orientation="Horizontal">
<Frame BackgroundColor="SkyBlue" HeightRequest="40" WidthRequest="40" CornerRadius="30" Padding="0" Margin="5">
<Image Source="https://images.all-free-download.com/images/graphicthumb/lock_icon_6813906.jpg" Aspect="AspectFill" Margin="0"/>
</Frame>
<Entry Placeholder="Password" IsPassword="True" TextColor="White" FontAttributes="None" HorizontalOptions="FillAndExpand" Margin="0,0,20,0"/>
</StackLayout>
</Frame>
<StackLayout Orientation="Horizontal">
<CheckBox IsChecked="False" Color="White" />
<Label Text="Remember me" TextColor="White" FontSize="Small" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" />
<Label Text="Forgot Password" TextColor="White" FontAttributes="Bold" HorizontalOptions="EndAndExpand" FontSize="Small" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" />
</StackLayout>
<Button Text="SIGN IN" BackgroundColor="#2b78d4" TextColor="White" CornerRadius="30" />
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Label Text="Still Not Connected ?" TextColor="White" FontSize="Small"/>
<Label Text="Sign Up" TextColor="White" FontAttributes="Bold" FontSize="Small"/>
</StackLayout>
<StackLayout Margin="0,25,0,0" Padding="0">
<Grid>
<BoxView BackgroundColor="White" HeightRequest="1" WidthRequest="150" HorizontalOptions="Center" VerticalOptions="Center"/>
<Frame BackgroundColor="White" HeightRequest="45" WidthRequest="45" CornerRadius="45" HasShadow="False" BorderColor="White" Margin="0" HorizontalOptions="Center" Padding="0">
<Label Text="OR" TextColor="White" FontSize="Small" VerticalTextAlignment="Center" HorizontalTextAlignment="Center"/>
</Frame>
</Grid>
</StackLayout>
<StackLayout Margin="0,25" Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Frame BackgroundColor="White" HeightRequest="45" WidthRequest="45" CornerRadius="45" HasShadow="False" BorderColor="White" Margin="0" HorizontalOptions="Center" Padding="0">
<Image Source="https://www.pngitem.com/pimgs/m/44-440455_transparent-background-fb-logo-hd-png-download.png" Aspect="AspectFill" Margin="0"/>
</Frame>
<Frame BackgroundColor="White" HeightRequest="45" WidthRequest="45" CornerRadius="45" HasShadow="False" BorderColor="White" Margin="0" HorizontalOptions="Center" Padding="0">
<Image Source="https://blog.hubspot.com/hubfs/image8-2.jpg" Aspect="AspectFill" Margin="0"/>
</Frame>
</StackLayout>
</StackLayout>
</StackLayout>
</Frame >
</StackLayout>
</StackLayout >
</ContentPage>
Solution
According to the documentation you need to set up experimental flags (In your target platforms projects) for some features that the development team is judging still in experimental phase, so that you acknowledge that before using them.
On android in will be in your MainActivity
class, on ios in AppDelegate
Class:
Forms.SetFlags("Brush_Experimental")
You can set several experimental flags at once like:
Xamarin.Forms.Forms.SetFlags(new string[] { "SwipeView_Experimental", "Shapes_Experimental", "AppTheme_Experimental" });
Note
Make sure to call SetFlags()
before Xamarin.Forms.Forms.Init()
Answered By - Cfun
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.