I'm trying to set tabs in my whole application.
I created a Tabbed page like this :
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:LogiStock.UI.Base.Views"
x:Class="Views.TabbedPage1" >
<!--Pages can be added as references or inline-->
<views:HomePage x:Name="Test" Title="AA"/>
I can navigate on other page from my HomePage but when I do that, my TabbedPage go away.
How can I keep the navigation inside my tab ?
Im using Xamarin 4.4 and Prism 7.2
The only change you need to do is something like:
<NavigationPage Title="AA" IconImageSource="icon.png">
<x:Arguments>
<views:HomePage x:Name="Test" />
</x:Arguments>
</NavigationPage
And then you can push pages to this navigation stack :)
Related
I am using Shell Tabbed Page, and it's working fine. But when I navigate to a new Page using
Navigation.PushAsync(new SecondPage());
Then inside the Second Page Shell Tabbed also showing, so I need to hide this shell from this page.
How to do this?
From Sheel backend cs page I can hide this,I also try with Messaging Center to hide this but its not working.
In your page just add:
Shell.TabBarIsVisible="False"
Here is a sample:
ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Shell.TabBarIsVisible="False"
x:Class="Sample.MySamplePage"
Title="TitleTest">
<StackLayout Spacing="20" Padding="15">
<Label Text="Hello Xamarin"/>
</StackLayout>
</ContentPage>
I am trying to implemenat a TabbedPage with Xamarin Forms. It is very similar to TabbedPage and Content pages are not showing
However I have a quick question as to how to include other xaml files from the MainPage.xam:
Here is my code:
MainPage:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Assignment"
x:Class="Assignment.MainPage">
<TabbedPage.Children>
<local:Alarm /> "The type 'local:Alarm' was not found. Verify that you are not missing..."
</TabbedPage.Children>
The above error is the only build error.
Alarm.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="Assignment.Droid.Resources.layout.Alarm">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
Here is my project structure:
On the other link, I saw that he put his xaml files in the layout folder.
Is this the correct setup? I think I have missed something simple.
As Greggz mentions: move it to your shared project.
Then you will have to change your namespaces because that is what actually matters. In .NET land, it is customary that your namespace equals the path on your filesystem.
In you Alarm.xaml, change this line: x:Class="Assignment.Droid.Resources.layout.Alarm" to x:Class="Assignment.Alarm".
Then go into your code-behind, the Alarm.xaml.cs file and change the namespace there too. So change namespace Assignment.Droid.Resources.layout to namespace Assignment.
Since the XAML and the code-behind are implemented as a partial class, this needs to be in sync.
I have a multiplatform app set up, so far it is working decently. My main issue though is I need to change the layout between IOS and Android. In my main solution I have a class called LocationView:
class LocationView : ContentView {
LocationView() {
InitializeView();
}
}
...and it's subsequent 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="Cabs.Views.LocationPage">
<ContentPage.Content>
<Label Text="I'm regular with a bunch of regular stuff" />
</ContentPage.Content>
</ContentPage>
For IOS, I need to change and subsequent controls (UIcontrols based, etc)
What is the correct way of doing this?
I know it has something to do w/ DI, not sure of the syntax. I tried the following:
[assembly: Dependency(typeof(LocationPage))]
It still isn't working
I try calling await Navigation.PushAsync(new DependencyService.Get<LocationPage>())
But I get a compile error
What is the correct procedure for this?
Thanks
Today i faced some issue. Please help me.
I created a cross platform application on IOS and Android. So i trying to access my MainPage controls form .cs file but i can't. Here is provided code.
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"
xmlns:local="clr-namespace:Movies"
x:Class="Movies.MainPage">
<TableView x:Name="mainTable">
<TableSection>
<ViewCell>
<ViewCell.View>
<Label Text="Hello"></Label>
</ViewCell.View>
</ViewCell>
</TableSection>
</TableView>
</ContentPage>
MainPage.xaml.cs
using Xamarin.Forms;
namespace Movies
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
mainTable.
}
}
}
https://i.imgur.com/OKO3yYc.png
Project runs successfully.
https://i.imgur.com/ondjVkP.png
I tried rebuild and even restore VS17 in VS installer.
this.mainTable doesn't work either.
Click on the .XAML file, select Properties.
See a Property called Custom Tool. Change its value from MSBuild:Compile to MSBuild:UpdateDesignTimeXaml or if it is blank set it to MSBuild:UpdateDesignTimeXaml.
This will solve the problem.
Build the project once,then you can access the name in .cs file.
Trying to figure out Xamaring and VS by playing around with it and I've had an issue with MasterDetailPages for a couple of days.
Process
Went from a blank file and turned the MainPage.xaml into the
MasterDetailPage
added a content page into MasterDetailPage.Master
and a content page into MasterDetailPage.Detail
Added a stack layout and a label into both of their ContentPage.Content and ran the project fine.
Thought I'd try out the next step and add a new xaml file as a reference ContentPage, but just with the .Master first. Code went from
<MasterDetailPage.Master>
<ContentPage Title="Master Page" Padding="10">
<ContentPage.Content>
<StackLayout Margin="5,30,5,5">
<Label Text="NavMenu Master Page"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
</MasterDetailPage.Master/>
//TO WHAT I HAVE BELOW THIS
<MasterDetailPage.Master>
<local:NavMenu Title=NavMenu/>
</MasterDetailPage.Master>
Ran the file and I got the error that is in the title. Tried to troubleshoot by rolling it back to the original conent and the error persisted. Created a new file, copied and pasted the code into the other file and it ran just fine.
I'm clueless to what the issued is and how I should go about fixing it.
With your first code, it isn't necessary to put ContentPage.Content as it is implicit that the code is child from that element. Other than that, your code seems to be fine.