This may be a dumb question, but here goes.
I have a simple app that plots points in a Xamarin.Forms.Map. My MainPage.xaml looks like this and it works as expected:
<?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:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
xmlns:local="clr-namespace:GasStations"
x:Class="GasStations.MainPage">
</ContentPage>
Instead of using this map, I would like to display the map from the Waze app.
Is it as easy as switching the control or is it more complex?
Related
i want to bind viewmodel to nested tab views in xamarin prism framework
i created 4 main pages(A,B,C,D) as main tabs and inside first tab(A) i created two more tabs(A1,A2).but data for nested tabs are not binding.even viewmodel for that views(A1,A2) are not hitting
MenuPage.xml
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.Views.MenuPage"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
xmlns:views="clr-namespace:MyApp.Views"
BarBackgroundColor="White"
android:TabbedPage.ToolbarPlacement="Bottom"
NavigationPage.HasNavigationBar="True">
<TabbedPage.Children>
<views:A Title="A" Icon="abc.png" />
<views:B Title="B" Icon="abc.png" />
<views:C Title="C" Icon="abc.png" />
<views:D Title="D" Icon="abc.png"/>
</TabbedPage.Children>
</TabbedPage>
and my page A is like
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:MyApp.Views"
x:Class="MyApp.Views.A">
<!--Pages can be added as references or inline-->
<TabbedPage.Children>
<views:A1 Title="A1" />
<views:A2 Title="A2" />
</TabbedPage.Children>
</TabbedPage>
and i have separate viewmodel for A1 and A2.
so if i directly bind A1 to main navigation page it will work properly and render data.but if i do like above viewmodel for A1 is not hitting the constructor and nothing is displaying apart from static data.i am new to tabbed page navigation.any help is appreciated.this the view i am trying t achieve
I find we should add AutowireViewModel in the page's XAML to load the view model we want:
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
Generally, we use containerRegistry.RegisterForNavigation<>(); to bind the custom view model to a certain view. But you placed a sub tabbed page in the root tabbed page. This caused the nested view losing the mapping to the corresponding view model. After adding the AutowireViewModel, this issue fixed. We could still use RegisterForNavigation to bind your custom view model to your special view instead of the automatic naming conversation.
Here is my sample for a simple nested tabbed page: https://github.com/landl0526/PrismTabDemo. Refer to it for more detailed code.
Moreover, this only works on the Android platform as iOS only has the bottom aligned tabbar.
The font that I have is too big for the amount of words that I would like to display. Does anyone have any suggestions as to how I can change the font size. I would prefer to be able to do it in the shared code but if it needs a custom renderer then can someone show me how this can be done?
So, if you are using Xamarin.Forms 3.2.0 or above, you can use TitleView property like this:
<?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="Xamarin.Forms.Controls.GalleryPages.TitleView">
<NavigationPage.TitleView>
<Label Text="This is my Title" FontSize="12" TextColor="White" />
</NavigationPage.TitleView>
<!-- YOUR CONTENT HERE-->
</ContentPage>
I'm making an app in Xamarin Forms and when I deploy it to Android, I get a weird problem. It appears that I have two toolbar items when I only declared one in XAML. Also, I believe this is proper behaviour, but I was wondering if it's possible to not display the navbar title on a lower line and rather display it upper center. Thanks!
Screenshot
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Biziboards.Views.MerchantListPage"
Title="Merchants">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Home"
x:Name="btnHome"
Clicked="btnHome_Clicked"
Order="Primary"/>
</ContentPage.ToolbarItems>
In your pages Xaml.cs file:
NavigationPage.SetHasNavigationBar(this, false);
I am working on an application where the developer has a <ContentPage> with a <TableView> inside. Is this needed / normal practice? I am trying to work out why the developer did this.
The developer added a element surrounding the <TableView>
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Title="Network">
<ContentPage.Content>
<StackLayout>
<TableView>
...
</TableView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
A ContentPage can only have a single child element. It's not uncommon to include some sort of Layout container as the child, so multiple child elements can be added to the page. However, in cases like this where there is really only a single child it's probably unnecessary.
Is anyone having trouble with the CalendarView component from XLabs? I have written the XAML code below, tried to run it on my Android device, and it displays just fine, only there's no way to change the current month (I'm expecting a swipe should work), nor can I see any navigation arrows.
Anyone got any idea what's going on?
<?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:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
xmlns:local="clr-namespace:TestXAML"
x:Class="TestXAML.MainPage"
Padding="10">
<controls:CalendarView
x:Name="calendarioConsultas"
HorizontalOptions="Fill"
ShowNavigationArrows="True"
BackgroundColor="Transparent"
NavigationArrowsColor="Black"
/>
</ContentPage>
Ok, I solved it by setting MinDate parameter to 01/01/1970. Turns out that navigation doesn't work unless you specify MinDate or MaxDate.