How to remove Actionbar In MAUI - c#

My XAML Code for view
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
BackgroundColor="White"
Title=""
x:Class="Chuxi.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
</VerticalStackLayout>
</ScrollView>
I have Tried C# Code TO Remove BUt Doesnt Working
public MainPage()
{
NavigationPage.SetHasNavigationBar(this, false);
InitializeComponent();
}
How Can I Remove Title Bar And Make It Full Screen View

This May Help You. Its working For me
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage NavigationPage.HasNavigationBar="false"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
BackgroundColor="White"
Title=""
x:Class="Chuxi.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
</VerticalStackLayout>
</ScrollView>
</ContentPage>
Any Issue ask me on comment. Thank You

Related

In Xamarin, How to use ContentView as UIView in IOS

I have a test page inherited from ContentView in Xamarin Forms.
I want to use it in IOS . But I have a conversion promlem (Can Not Convert from ContentView to UIView)
My test page is below.
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class=".....TestPage">
<ContentView.Content>
<StackLayout>
<Label x:Name="TestLabel"
Text="TEST PAGE OPENING"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentView.Content>
</ContentView>
My IOS Function is below.
public override void ViewDidLoad()
{
TestPage page = new TestPage();
View.AddSubview(page);
base.ViewDidLoad();
}
Looking for your helps.
Thanks!

Xamarin Forms Image AspectFill isn't working correctly

Can anyone tell me why this image isn't filling the screen? Is there a known bug with "AspectFill" on Android emulators?
<?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="HelloWorld2.AbsoluteLayout_Exercise2">
<AbsoluteLayout>
<Image Source="AbsoluteLayout_Exercise2.jpeg" `Aspect="AspectFill"/>
</AbsoluteLayout>
</ContentPage>
I needed to leverage the AbsoluteLayout.LayoutBounds to scale the image. I now have the desired result.
<AbsoluteLayout VerticalOptions="FillAndExpand">
<Image Source="AbsoluteLayout_Exercise2.jpeg" Aspect="AspectFill"
AbsoluteLayout.LayoutBounds="1,1,1,1"
AbsoluteLayout.LayoutFlags="All"/>
</AbsoluteLayout>

There is a way to show some content in a Xamarin Page XAML based on a variable?

I'm trying to write a page that must show some content based on a variable in the binded class.
For example:
<?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="MyProject.MyClass"
Title="Beautiful Title">
<ContentPage.Content>
//If something true in the MyClass.cs
<StackLayout>
<Label Text="Yeeee" />
<ListView>
...
</ListView>
</StackLayout>
//Else
<AbsoluteLayout>
<Label Text="Noooo" />
<Button>
...
</Button>
</AbsoluteLayout>
</ContentPage.Content>
</ContentPage>
There is a way to do that? My goal is to write a single page instead of two page that differs for few lines of code.

Xamarin base ContentPage with loading (or common ContentViews)

how can I create a "base" ContentPage that contains, for sample, a busy indicator, and make this Page the base for each other pages inside my application?
I have tried to do in this way, but the busy indicator isn't showed.
Base Page:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:core="clr-namespace:SgatMobileV3.Core;assembly=SgatMobileV3"
x:Class="SgatMobileV3.Core.BasePage">
<ContentPage.Content>
<Grid>
<core:VolosLoadingView />
</Grid>
</ContentPage.Content>
</ContentPage>
Busy indicator view:
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:core="clr-namespace:SgatMobileV3.Core;assembly=SgatMobileV3"
core:LocatorViewModel.AutoWireViewModel="true"
x:Class="SgatMobileV3.Core.VolosLoadingView"
xmlns:busyindicator="clr-namespace:Syncfusion.SfBusyIndicator.XForms;assembly=Syncfusion.SfBusyIndicator.XForms">
<Grid>
<Grid BackgroundColor="LightGray" Opacity="0.6" IsVisible="True" />
<busyindicator:SfBusyIndicator
IsBusy="True"
IsVisible="True"
x:Name="loading" AnimationType="DoubleCircle"
ViewBoxWidth="150" ViewBoxHeight="150"
TextColor="Green" BackgroundColor="Transparent"
HorizontalOptions="Center" VerticalOptions="Center"/>
</Grid>
</ContentView>
A page:
<core:BasePage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:core="clr-namespace:SgatMobileV3.Core;assembly=SgatMobileV3"
core:LocatorViewModel.AutoWireViewModel="true"
x:Class="SgatMobileV3.Views.MockPage">
<ContentPage.Content>
<Grid>
<Button Text="Welcome to Xamarin.Forms! 1"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
Command="{Binding Test_ClickCommand}" />
</Grid>
</ContentPage.Content>
</core:BasePage>
I have tried to include a sample label inside the base page but nothing appears.
how can I create a "base" ContentPage that contains, for sample, a busy indicator, and make this Page the base for each other pages
If want Creating a ControlTemplate at Page Level,creating ControlTemplate instances at the application level, they can also be created at the page level, as shown in the following code example:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SimpleTheme.HomePage">
<ContentPage.Resources>
<ResourceDictionary>
<ControlTemplate x:Key="TealTemplate">
...
</ControlTemplate>
<ControlTemplate x:Key="AquaTemplate">
...
</ControlTemplate>
</ResourceDictionary>
</ContentPage.Resources>
<ContentView ... ControlTemplate="{StaticResource TealTemplate}">
...
</ContentView>
</ContentPage>
When adding a ControlTemplate at the page level, a ResourceDictionary is added to the ContentPage, and then theControlTemplate` instances are included in the ResourceDictionary.
And also can use code , from doc has a sample for example.
You can do that adding the control in the code (in BasePage.cs file), I don't think there is XAML solution for that.

Content of child page doesn't show in tabbedpage (Xamarin Forms)

I'm new to Xamarin and XAML so i downloaded a sample solution which has 3 tabbed pages and each of them contains a child page. Each child page has a label with different text on it. I managed to write a program that is supposed to do the same thing, but the label doesn't show on any of the child pages. I can change the background color and title on the child pages.
Here's the code for the MainPage (TabPage):
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:MozaikMuzeum_Xamarin.View;assembly=MozaikMuzeum_Xamarin"
x:Class="MozaikMuzeum_Xamarin.View.TabPage">
<TabbedPage.Children>
<pages:ActualPage />
<pages:CatalogPage />
<pages:BadgesPage />
</TabbedPage.Children>
</TabbedPage>
And here's the code for one of the child pages:
<?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="MozaikMuzeum_Xamarin.View.ActualPage" Title="Aktuális" BackgroundColor="Green">
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
<ContentPage.Content>
<Label Text="Hi there from Page 1" TextColor="White" Font="20"
VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage.Content>
</ContentPage>
As you can see the label doesn't show between the ContantPage.Content tags.

Categories