Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 79144 articles
Browse latest View live

Custom View Above Toolbar in Android ?

$
0
0

Is it possible to have view above the toolbar like below in Android and UWP? I mean even naively can you add a some progress bar on top regardless of where you navigate it remains on display.


on shell I have problem with bottomview renderer how we can solve?

$
0
0

As you see bottomview sliding tabs like strange because I use fontimages and state problem when ı click first time it is working wrong second click working right is anyone help me thanks?

[assembly: ExportRenderer(typeof(AppShell), typeof(CShellRenderer))]
namespace Goo4.Droid.Renderers
{
public class CShellRenderer : ShellRenderer
{
public CShellRenderer(Context context) : base(context)
{
}
protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
{
return new CBottomNavViewAppearance();
}

}


public class CBottomNavViewAppearance : IShellBottomNavViewAppearanceTracker
{
    public void Dispose()
    {

    }

    public void ResetAppearance(BottomNavigationView bottomView)
    {

    }

    public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
    {




        bottomView.SetBackgroundColor(Android.Graphics.Color.ParseColor("#ffffff"));



        //Change colors on different states

        int[][] states = new int[][]{
                new int[]{-Android.Resource.Attribute.StateChecked},  // unchecked
                new int[]{Android.Resource.Attribute.StateChecked},   // checked
                new int[]{}                                // default
        };

        int[] colors = new int[]{
                Android.Graphics.Color.ParseColor("#dddddd"),
                Android.Graphics.Color.ParseColor("#fb666b"),
                Android.Graphics.Color.ParseColor("#dddddd"),
        };

        ColorStateList navigationViewColorStateList = new ColorStateList(states, colors);
        bottomView.ItemIconTintList = navigationViewColorStateList;
        bottomView.ItemTextColor = navigationViewColorStateList;


    }

}

}

Xamarin Experiment - SetFlags - AppTheme_Experimental

$
0
0

I have decided to update a Xamarin Forms app to XF 4.8. I have written some AppThemeColor for the handling of dark mode. Everything worked fine in XF 4.6. Upgrading to XF 4.8 has produced an error now where I am getting the error that AppThemeColor does not exist and wondering if I have referenced all of my assemblies. Previously, there had been a problem with the the XF 4.7 and needing to opt into the experimental theme features. Ok, so I go into my App.xaml.cs class and into the App initializor and call:

Device.SetFlags(new string[] {"AppTheme_Experimental"});

No love. Ok, so I try this in the iOS and Android projects to set the flags programmatically in the FinishedLaunching and the OnCreate methods. Still no love. I continue to get the errors.

Personally, I would think that I need to do something in a project options setting to get the compiler to pick this up, but I don't see anything.

Question: How do I turn on the AppThemeColor so that it will compile properly?

TIA, Wally

Adding image in grid, left some empty space

$
0
0

I want to put some labels on the image, so I have put image in grid but putting image in grid left some empty space below where as in stacklayout it is displaying fine.
Here is my code:
<StackLayout> <Grid BackgroundColor="Yellow" Margin="10"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Image Source="bg_with_border_1"/> </Grid> <StackLayout BackgroundColor="Pink" Margin="10"> <Image Source="bg_with_border_1"/> </StackLayout> </StackLayout>

How to use safe area in xamarin.forms android?

$
0
0

I am using xamarin.forms shell and the page is a shell page.

here is the code:
<StackLayout> <CarouselView ItemsSource="{Binding Banners}" IsSwipeEnabled="True" IsScrollAnimated="True" IsBounceEnabled="True" HeightRequest="214.67"> <CarouselView.ItemTemplate> <DataTemplate> <Frame IsClippedToBounds="True" CornerRadius="10" Margin="0" Padding="0" BackgroundColor="Orange"> <ff:CachedImage VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Margin="0" DownsampleToViewSize="True" Aspect="AspectFit" Source="{Binding ImageUrl}" HeightRequest="214.67"/> </Frame> </DataTemplate> </CarouselView.ItemTemplate> </CarouselView> </StackLayout>
and here is the renderer:

Question 1:

how to use the safearea in the top?(android) I want to the Image in the top.

Question 2:

How to make the image full of the screen width? there is a orange place .I want to the image full of the whole width?

thank you.

Screeen is stuck after xamarin.forms updated

$
0
0

Hi all, Newbie is here..
i am using xamarin.forms in my app and i had to update it for some reason.. The was working fine until update. but now only when try to load the products page, loading screen is stuck.. When i debug, i dont get any error or anything.
old version 3.4.0.. new stable version is 4.8.0.1269..

and this is the code where it is stuck. up until the update, it was working fine. thanks alot for your answers.

    private async void getData()
    {
        try
        {
            if (_search == null)
            {
                Config.ShowDialog();
                var products = new ProductResponce();
                if (Application.Current.Properties.ContainsKey("user_id"))
                {
                    products = await ProductLogic.GetProducts(_category_id, Application.Current.Properties["user_id"].ToString());
                }
                else
                {
                    products = await ProductLogic.GetProducts(_category_id, null);
                }
                if (products.status == 200)
                {
                    Config.HideDialog();
                    if (products.data != null)
                    {
                        ViewModel.Products = new ObservableCollection<Product>(products.data.ToList());
                        //listProducts.FlowItemsSource = products.data.ToList();
                        listProducts.ItemsSource = products.data.ToList();
                    }
                    else
                    {
                        EmptyProducts();
                    }
                }
                else
                {
                    EmptyProducts();
                }
            }
            else
            {
                Config.ShowDialog();
                var products = new SearchProductResponce();
                if (Application.Current.Properties.ContainsKey("user_id"))
                {
                    products = await ProductLogic.GetSearchProducts(_search, Application.Current.Properties["user_id"].ToString());
                }
                else
                {
                    products = await ProductLogic.GetSearchProducts(_search, null);
                }
                if (products.status == 200)
                {
                    Config.HideDialog();
                    if (products.data != null)
                    {
                        listProducts.ItemsSource = products.data.ToList();
                        //listProducts.FlowItemsSource = products.data.ToList();
                        ViewModel.Products = new ObservableCollection<Product>(products.data.ToList());
                    }
                    else
                    {
                        EmptyProducts();
                    }
                }
                else
                {
                    Config.HideDialog();
                    EmptyProducts();
                }
                Config.HideDialog();
            }
        }
        catch (Exception ex)
        {
            Config.ErrorStore("ProductsPage-getData", ex.Message);
            Config.HideDialog();
            EmptyProducts();
            Config.ErrorSnackbarMessage(Config.ApiErrorMessage);
        }
    }

Set Orientation in all pages

$
0
0

Hi everyone, I'm having trouble setting the Orientation. In the OnCreate function in the MainActivity of my Android set
This.RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;
It's a good working
In another handler, I call the event logout
public partial class DataClient
{
public static event EventHandler OnLoggedOut;
........
Device.BeginInvokeOnMainThread(() =>
{
if (OnLoggedOut != null)
OnLoggedOut(typeof(DataClient), EventArgs.Empty);
});
}
This logout function removes the corresponding content pages. The problem is that after the removal is complete, setting Orientation = Portrait at first no longer works, anyone who has this situation can help me thank you, everyone!

Which push notification integration would you recommend for Xamarin Forms in 2020?

$
0
0

Hi everyone !
I need your ideas. A few years ago, I integrated Push Notification for Xamarin Forms via AppCenter. But, then I guess the push notification service was removed from the AppCenter.

Which integration do you think I should use to send detailed push notifications for Xamarin Forms?

Thanks in Advance !


Why this forum site has suddenly become monochrome?

$
0
0

Just from Monday (Aug 10) or so this site is all black & white except for the profile photos/icons.

Any good reason for it?

How can i focus the particular stacklayout when clicking the button ?

$
0
0

I'm new to xamarin can anyone help ,when tapping the image button it will focus the particular stacklayout in xamarin forms

Xamarin Forms - Cascading ListView/CollectionView cell animation

$
0
0

In our project, we got a requirement to implement something like a cascading ListView cell animation (cell loads up one-by-one, instead of just in one shot). What are my options to implement it easily in Xamarin Forms? Would I have to go in the direction of writing Custom Renderer to implement it? The example is given in the below animation.

Any suggestions are much appreciated.

Thank you in advance.

Insecure HttpClientHandler works in iOS but not in Android - Connection Reset by Peer

$
0
0

Hello

I am developing a cross platform app for Android and iOS.
I am using an insecure HttpClientHandler for a HTTPS connection with my webservice.

It is a strange issue. I can connect to the web service on my machine with both Android device and iOS emulator but with another server, the connection only works with iOS.

With Android , I get the following error:
The SSL connection could not be established, see inner exception.
Inner exception ->
Unable to read data from transport connection. Connection reset by peer. error code 10054.

I have already checked that both my machine and server have a valid SSL certificate assigned to the required port.
The service running is the same on both. iOS app works, Android doesn't.

Any ideas??

Binding not working OnNavigatedTo

$
0
0

When I use my Property in constructor he is working normal, but if I use from OnNavigatedTo by Prism, to set Position on CarouselView its not working, and if I use it after this method property working normal.
public CarouselImagePageViewModel(INavigationService navigationService, IDialogService dialogService)
{
_dialogService = dialogService;
_navigationService = navigationService;
DeleteImageCommand = new DelegateCommand(DeleteImage, CanDeleteImage);
//Working
ImagePosition = 4;
}public void OnNavigatedTo(INavigationParameters parameters)
{
if (parameters["images"] is List images)
{
Images.Clear();
foreach (var x in images)
{
Images.Add(x);
}
}
//Путь к нажатому изображению
if (parameters["currentImage"] is FImage image)
{
CurrentImage = image;
//Not working
ImagePosition = 3;
//ImagePosition = Images.IndexOf(image);
}
}
}`
Whats my problem?

Custom font not working

$
0
0

Hi

I am using Xamarin.Froms 4.8 with latest version of VS 2019 and Xamarin files.

I added the font file ionicons.ttf to \Resources\fonts\ folder in the platform agnostic project and set it as Embedded Resource.

I added below in AssemblyInfo.cs;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
[assembly: ExportFont("ionicons.ttf", Alias = "ionicons")]

In AppShell.xaml I have;

<FlyoutItem Title="My App" FlyoutDisplayOptions="AsMultipleItems">
        <Tab.Icon>
            <FontImageSource FontFamily="{StaticResource ionicons}" Glyph="&#xF445;" Size="Small"/>
        </Tab.Icon>
        <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
    </Tab>
</FlyoutItem>

I am getting the StaticResource not found for key ionicons' error in AppShell.xaml.g.cs. Screen attached.

How can I make the font work please?

Thanks

Regards

CarouselView implementation, CardsView nuget package


In a XF.iOS app, while Google Authentication, a warning appears but the SignIn page is not displayed

$
0
0

While doing Google API Authentication, the following warning is printed in Output window and the Google Sign-in page is not displayed in iOS.

2020-08-10 14:13:22.320667-0400 MyProject.iOS[8180:232198] Warning: Attempt to present on whose view is not in the window hierarchy!

But in another exploratory app this doesn't happen. What is wrong with 'MyProject'?

My carousel no change of position when i set the value of property from code

$
0
0

Im have a carousel (https://github.com/alexrainman/CarouselView) where the user can see samples, these samples are added one by one, and the user could see the last one created each time that he press the button, in android the project works fine, but in iOS the carousel has a very strange behavior, because when user press button add(see below) in the carousel only appears the first and last elements in the item source :S

I attached some code to understand better this situation.

xmla page

<controls:CarouselViewControl x:Name="cvSamplings" ItemsSource="{Binding ListSamplings, Mode=TwoWay}" PositionSelected="cvSamplings_PositionSelected"
                                      Orientation="Horizontal" InterPageSpacing="10" Position="{Binding MyPosition,Mode=TwoWay}"                                        
                                      VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">

code to change current position

var index = viewModel.AddSample();
BindCarouselView();
viewModel.MyPosition = index;

How to show in webview the default site login prompt

$
0
0

Hi. I wanted to know if it was possible to show the login prompt of a site that requires Windows authentication.
If I use a webview and point to the site, the denied login page is shown immediately.
I should then first enter my login credentials into the login prompt and then if correct display the home page.
Thank you.

Edit styles.xml in C#

$
0
0

Hello everybody!

I have the following problem. I want to change the color of the status bar on Android in code. (The top bar that shows the time, battery, etc.). I know that I can change the background color of the bar in styles.xml in the Android project as follows:

 <item name = "colorPrimaryDark"> # ffffff </item>

And I can switch the text color between black and white as follows:

 <item name = "android: windowLightStatusBar"> true </item>

But how can I set these values in C # without the styles.xml?

ListView not working with list of images in code behind

$
0
0

I have a listView bound to a list in the code behind. The model contains 4 items of data, one of which is an image. All of the items display correctly except the image (which is blank) and I need help figuring out why.

If in the for loop I limit it to just one iteration i.e. i < 1 then displaying a single image works. It's just when I try to display more than one that the image are blank

XAML:

   <ListView BackgroundColor="White" x:Name="Items" HasUnevenRows="True">
     <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>                            
                                <StackLayout Padding="5" Orientation="Horizontal">
                                    <Image Source="{Binding imageSource}" HorizontalOptions="Start" WidthRequest="70" HeightRequest="50" />
                                    <StackLayout HorizontalOptions="CenterAndExpand">                                      
                                        <StackLayout VerticalOptions="Center" Orientation="Horizontal">                                                
                                            <Label Text="{Binding FileType}"></Label>
                                            <Label></Label>
                                            <Label Text="{Binding FileSize}"></Label>
                                        </StackLayout>
                                        <Label HorizontalOptions="CenterAndExpand" Text="{Binding DateCreated}"></Label>                                            
                                    </StackLayout>                               
                                    <Label HorizontalOptions="End" Text="Status" VerticalOptions="Center"></Label>                          
                                </StackLayout>                            
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>  

CODE BEHIND:

        FileModel fileModel = DependencyService.Get<IImageFetcher>().ReadImagesAsync();

        var items = new List<FileImageInfo>();
        for (int i = 0; i < fileModel.Images.Count; i++)
        {
            var imageStream = ImageSource.FromStream(() => new MemoryStream(fileModel.Images[i]));
            items.Add(new FileImageInfo
            {
                FileType = "Jpeg",
                FileSize = fileModel.Sizes[i],
                DateCreated = fileModel.Dates[i],
                imageSource = imageStream
            });
        }
        Items.ItemsSource = items;

Viewing all 79144 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>