I have a floating menu and there are 3 pages in it, but when I navigate to those pages it shows an animation as if the page is coming from the inside out. Only happens with the hamburger menu, with the TabBar that does not happen.
<FlyoutItem Title="Home" Route="HomePage">
<Tab>
<ShellContent ContentTemplate="{DataTemplate home:HomePage}" Style="{StaticResource HomePageShell}" />
</Tab>
<FlyoutItem.Icon>
<FontImageSource
FontFamily="FontAwesome"
Glyph="{x:Static fontello:FontAwesomeIcon.Home}"
Color="Black" />
</FlyoutItem.Icon>
</FlyoutItem>
<FlyoutItem Title="Perfil" Route="PerfilPage">
<Tab>
<ShellContent ContentTemplate="{DataTemplate perfil:PerfilPage}" Style="{StaticResource PerfilPageShell}" />
</Tab>
<FlyoutItem.Icon>
<FontImageSource
FontFamily="FontAwesome"
Glyph="{x:Static fontello:FontAwesomeIcon.UserCircleO}"
Color="Black" />
</FlyoutItem.Icon>
</FlyoutItem>
<FlyoutItem Title="Atención al cliente" Route="SoportePage">
<Tab>
<ShellContent ContentTemplate="{DataTemplate soporte:SoportePage}" Style="{StaticResource SoportePageShell}" />
</Tab>
<FlyoutItem.Icon>
<FontImageSource
FontFamily="Gadgets"
Glyph="{x:Static metroStudio:GadgetsIcon.HeadphoneMike}"
Color="Black" />
</FlyoutItem.Icon>
</FlyoutItem>
Is this what you are looking for.
Look here in the Docs.
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/flyoutpage#navigation-behavior
The behavior of the navigation experience between flyout and detail pages is platform dependent:
On iOS, the detail page slides to the right as the flyout page slides
from the left, and the left part of the detail page is still visible.
On Android, the detail and flyout pages are overlaid on each other.
On UWP, the flyout page slides from the left over part of the detail
page, provided that the FlyoutLayoutBehavior property is set to
Popover.
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/flyoutpage#control-the-detail-page-layout-behavior
How the FlyoutPage manages the flyout and detail pages depends on whether the application is running on a phone or tablet, the orientation of the device, and the value of the FlyoutLayoutBehavior property. This property determines how the detail page will be displayed. It's possible values are:
Default – The pages are displayed using the platform default.
Popover – The detail page covers, or partially covers the flyout
page.
Split – The flyout page is displayed on the left and the detail page
is on the right.
SplitOnLandscape – A split screen is used when the device is in
landscape orientation.
SplitOnPortrait – A split screen is used when the device is in
portrait orientation.
Example in xaml for FlyoutLayoutBehavior
<FlyoutPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FlyoutPageNavigation.MainPage"
FlyoutLayoutBehavior="Popover">
...
</FlyoutPage>
Related
is it possible to round the corners of the XCT popup?
I tried to set the BackgroundColor to transparent, and to set the body in a frame with the option CornerRadius - but this does not work as desired.
Does anyone have a tip on how to round the corners?
<xct:Popup xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CashTracker.Views.ImagePopup"
xmlns:viewmodels="clr-namespace:CashTracker.ViewModels"
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.UI.Views;assembly=Xamarin.CommunityToolkit"
Size="300,400"
BackgroundColor="Transparent">
<Frame CornerRadius="20" HasShadow="True">
<StackLayout>
<Label Text="Aufgenommenes Foto" FontSize="Medium" HorizontalOptions="Center"/>
<Image x:Name="PopupImageSource"/>
</StackLayout>
</Frame>
</xct:Popup>
Xamarin XCT Popup
The popup should look like this - only without the white corners.
Xamarin Popup Frame
Somehow BackgroundColor was not working for Popup. Hence use the Color propperty for setting color of the Popup.
If you are using Frame in your layout, you can use Frame's CornerRadius for rounded corners (only if you are using Frame).
If you are not using Frame then you can use Xamarin Community Toolkit's CornerRadiusEffect.CornerRadius to set CornerRadius for any Layout, View or Control.
Hence for your question, it can be done by setting Popup's color as Transparent and your content's parent element must have property for corner radius and must have BackgroundColor set to White or any other Color as your Popup`s color is Transparent.
Here's the XAML
<xct:Popup ...
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.UI.Views;assembly=Xamarin.CommunityToolkit"
Size="300,400"
Color="Transparent">
<Frame CornerRadius="20" HasShadow="True">
<StackLayout>
<Label Text="Aufgenommenes Foto" FontSize="Medium" HorizontalOptions="Center"/>
</StackLayout>
</Frame>
//OR, if you don't need Frame then,
<StackLayout BackgroundColor="White" xct:CornerRadiusEffect.CornerRadius="10">
<Label Text="Aufgenommenes Foto" FontSize="Medium" HorizontalOptions="Center"/>
</StackLayout>
</xct:Popup>
There are lot of bugs in Xamarin Community Toolkit controls and views, we need to have some work-around for every control. Be it XCT's Popup, TabView, or extensions such as CornerRadius, ShadowEffect, TouchEffects, NativeAnimations, etc. The Community can't provide a single control without any bugs. But still, there are lots of useful features in XCT, hence we can only hope that the bugs are fixed, although the focus of fixing bugs if moved on to MAUI's Community Toolkit, until then we can use some work-arounds till stable and useful version of MAUI is released (considering its current status while writing this answer).
I am building this view currently:
This is a snapshot of the ios render, the code simply is:
<StackLayout>
<Image Source="img_logo"/>
</StackLayout>
But Android is not quite the same:
I tried everything, giving it verticaloptions, horizontaloptions, changing the aspect to everything, the image is never displayed as it is in ios. It is either clipped, or loses its original aspect ratio. I dont know what else to try here and why I have to do anything in the first place. Please tell me the atributes I need to use...
This code is expected to be rendered differently in some cases.
It is very important what is the target screen density of the image in your platform project. If it is different then obviously it will be rendered at a different size with the code above.
If you want to achieve the same look set the Width or Height property or both. Assuming that the container allows those values (that it is big enough) it will look exactly the same then.
If you want to adjust adjust the size of the image according to the space ratio of different views on the page, you can use Grid to achieve this.
You can set the width to Star or a special value.
For more about this, you can check rows-and-columns.
You can refer to the following code:
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="200" />
</Grid.RowDefinitions>
<!-- Logo -->
<Image Grid.Row="0"
Source="test.png"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
/>
<!-- Sign In Button -->
<StackLayout Grid.Row="1" Padding="10,0,10,0" VerticalOptions="Center">
<Button VerticalOptions="Center" Text="Sign In " />
</StackLayout>
</Grid>
</ContentPage.Content>
I'm using "Sharpnado Tabs" and having problem in firing tap event in middle "BottomTabItems".
I have 5 bottom tabs as you can see the attached photo and the areas outlined with black is firing tap event and changing the views accordingly. However, the areas marked with white, is not doing anything.
EDIT
The 5 tabs are spread evenly across the bottom panel. I have set the middle tabs' background to red to see the area they cover and where the touch is working. Setting InputTransparent="true" removes the touch event from the whole area of the tab.
<sho:ViewSwitcher x:Name="Switcher"
Grid.Row="0"
Grid.RowSpan="3"
Animate="False"
SelectedIndex="{Binding SelectedViewModelIndex}">
<sho:LazyView x:TypeArguments="pages:ProfilePage" BindingContext="{Binding ProfilePageViewModel}" />
</sho:ViewSwitcher>
<Image Source="navigationbackground.png" Grid.Row="3" TranslationY="5" />
<sho:TabHostView x:Name="TabHostLogo"
Grid.Row="3"
WidthRequest="200"
HeightRequest="60"
Margin="0"
Padding="0,20,0,0"
HorizontalOptions="Fill"
VerticalOptions="Start"
BackgroundColor="Transparent"
IsSegmented="False"
Orientation="Horizontal"
TabType="Fixed"
SelectedTabIndexChanged="TabHostLogo_SelectedTabIndexChanged"
SelectedIndex="{Binding Source={x:Reference Switcher}, Path=SelectedIndex, Mode=TwoWay}">
<sho:TabHostView.Tabs>
<sho:BottomTabItem IconImageSource="homeiconselected.png" IconSize="20" />
<sho:BottomTabItem IconImageSource="profileicon.png" IconSize="20"/>
<sho:TabButton x:Name="TabButton"
IsVisible="True"
ButtonBackgroundColor="Transparent"
ButtonCircleSize="40"
CornerRadius="40"
IconImageSource="navigationaddbutton.png"
TapCommand="{Binding ProfileViewCommand}"
Scale="2.5"
Margin="0,0,0,15"
TranslationY="-20" />
<sho:BottomTabItem IconImageSource="chaticon.png" IconSize="20"/>
<sho:BottomTabItem IconImageSource="moreicon.png" IconSize="20"/>
</sho:TabHostView.Tabs>
</sho:TabHostView>
The problem is caused by Scale attribute. Unfortunately, that scales the entire tab area, not just the circle button. At Scale=2, half of each of the surrounding buttons are blocked by an invisible expanded tab rectangle (that surrounds the middle tab button).
As you discovered, at Scale=2.5, more than half of the surrounding tabs are invisibly blocked.
I did not find any way to work around this bug. (Other than not using Scale - but then the button is either too small or not a circle, depending on values you use for ButtonCircleSize and CornerRadius.)
I recommend raising this as an issue at github Sharpnado.Tabs issue.
If you do, include a link in that issue to this SO Q&A. And add a link to bottom of your question to that issue - so people can track progress.
I have a problem with my Images. I have added some Images to my solution, for the Flyoutitems.
The Images are shown in th Flyout but not in the tabbar in the bottom.
AppShell.xaml
<FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
<ShellContent Title="News" Icon="tab_feed.png" Route="NewsPage" ContentTemplate="{DataTemplate local:NewsPage}" />
<ShellContent Title="Über den Verein" Icon="tab_team.png" Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
<ShellContent Title="Termine" Icon="tab_calendar.png" Route="TerminPage" ContentTemplate="{DataTemplate local:TerminPage}" />
</FlyoutItem>
Icon="tab_team.png" and Icon="tab_calendar.png" is shown in the Flyout not in the tabbar in the bottom.
I have checked the properties (filelocation, size, build action) of the Images themself, and they are the same as for the Icon="tab_feed.png", which is working fine.
Do you have any hint, what can be wrong with the images.
The icons of the Toolbar may be tinted in Shell. Plase use a monochrome png with transparent background (such as the tab_feed.png) to display the icon. Try to make the image transparent and test again.
Similar issue: https://forums.xamarin.com/discussion/185681/xamarin-forms-tabbedpage-iconimagesource-not-showing-in-ios
I have an app that uses the new Shell in Xamarin.Forms. I added the following code to one of my pages in an attempt to use the TitleView area to display my app header image centered. (FYI - I have tried Center for both of the alignment options and it made no difference.)
<Shell.TitleView>
<Image Source="UCIApp.png"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand" />
</Shell.TitleView>
What I get after doing this is the image in the title bar but centered in the space the excludes the hamburger button on the left as shown below:
What I would prefer is it centered regardless of the space the hamburger menu takes up looking something like this:
Any suggestions?
ALSO - Putting the image in the TitleView is causing it to be shrunk down. Is there any way to avoid that?
Yes, design fail and there is no option customization. I prefer Grid for like this problems. You can use column or row with percentage.
Default place.
<Shell.TitleView>
<Grid>
<ffimageloadingsvg:SvgCachedImage
Source="https://stackoverflow.design/assets/img/logos/so/logo-stackoverflow.svg"
Margin="10"/>
</Grid>
</Shell.TitleView>
In this example 4/5 unit first column and 1/5 unit second column (* sign presents percentage or divide).
<Shell.TitleView>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<BoxView BackgroundColor="Yellow"/>
<BoxView Grid.Column="1" BackgroundColor="LightGoldenrodYellow"/>
</Grid>
</Shell.TitleView>
Then add image text or control to prefered layout (image control default column is 0).
<Shell.TitleView>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<ffimageloadingsvg:SvgCachedImage
Source="https://stackoverflow.design/assets/img/logos/so/logo-stackoverflow.svg"
Margin="10"/>
</Grid>
</Shell.TitleView>
Edit: Add min height to grid or image control for prevent resize content. Also ffimageloadingsvg is third party package for loading svg files.
I think that's the designed problem about Shell Title View ,you can submit it as a
feature request in GitHub here .
What I would prefer is it centered regardless of the space the hamburger menu takes up looking something like this: ... Any suggestions?
The title view already been placed center in Title View . However , it looks like not center in the whole Navigation Bar . Have a look at follow code and effect .
<Shell.TitleView>
<StackLayout HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
BackgroundColor="Accent">
<Image Source="xamarin_logo.png"
HorizontalOptions="Center"
VerticalOptions="Center" />
</StackLayout>
</Shell.TitleView>
The effect :
You can see that the content of Title View , And the icon already been center in Title View .Because of existing meun icon , the weight of Title View is not equal with Navigation Bar .
Putting the image in the TitleView is causing it to be shrunk down
Refer to above effect , you can see that The size of the icon is adapted to the Title View display, and you can see the size of the Title View, so your icon is unlikely to exceed the display range of the Title View.