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

Hide/show NavigationBar without moving the ContentPage up/down

$
0
0

Hi everyone!

I am using GestureRecognition (a tap on the screen) to make the NavigationBar appear and disappear.

The problem I found is that when I do this, the whole ContentPage moves down/up as the NavigationBar appears/disappears, but I need it to stay exactly on the same scroll position.

I thought about auto-scrolling up/down the exact height of the NavigationBar, but maybe there is another way?
The problem with this is that I need to get the NavigationBar height, and apparently is not that easy.

I found this post: https://forums.xamarin.com/discussion/comment/415161#Comment_415161
But I don't know how to access the variable.

Am I solving it the right way? If it is the right way, can someone help me to understand how to get the var Height from another class?

Thanks a lot!!


In-App camera function

$
0
0

Hi all,

My app uses the standard camera for taking pictures (iOS and Android), but since I want to change the behaviour of the camera itself I need to create an in-app camera. I took a look at the ConferenceVision example, which seems pretty good for me: https://github.com/microsoft/ConferenceVision . The user in my my app has to take a picture, view it, and if the picture is good enough send it to an API.

Problem is that I cannot get it working in my app. It doesn't show the camera permissions somehow (it doesn't ask for any permissions), which causes the app to not show the camera.

I made a simple demo in the attachment, I hope someone can help me with this.

Listview auto scroll one item at a time

$
0
0

I have listview which has a story with around 50-60 rows. I want to slowly scroll listview automatically.
So that user can continue to read without manually scrolling.

button click on xamarin forms map infowindow's button

$
0
0

Hi,

I am showing infowindow on click of map pin. In infowindow I am showing text, spinner and button.

void OnInfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
{
var customPin = GetCustomPin(e.Marker);
if (customPin == null)
{
throw new Exception("Custom pin not found");
}

        if(customPin.Name != null)
        {
            var address = Android.Net.Uri.Parse("https://google.com");
            var intent = new Intent(Intent.ActionView, address);
            intent.AddFlags(ActivityFlags.NewTask);
            Android.App.Application.Context.StartActivity(intent);
        }
    }

when I am clicking on infowindow or any control like spinner or button, it is redirecting me on google.com which I have written in my code.

I do not have any idea how can I handle button click event and spinner selection change here.

Can anyone suggest me the way to handle it?

Xamrain Forms app templates

$
0
0

Hi

I‘m a dot net developer but digging first time into Xamarin. My first Xamrain Forms app needs a few simple screens; a list screen, a simple vertical stacked gallery, a news page with pic, headline and synopsis. App would be mostly UI, bound to backend remote api.

I wondering if I there are any page/app templates that I can use to jump start development while I am still learning Xamrain Forms. Any pointers would be appreciated.

Thanks

Regards

Exception using FilePicker plugin in iOS

$
0
0

I am getting the following exception when using Xam.Plugin.FilePicker in iOS:

System.NotImplementedException
Message=This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.

I just followed the steps detailed here.

Xamarin Forms: How to set a list of items as the Expander Child?

$
0
0

I am using an Expander for showing units and chapters of a book. I am able to show the units as the Expander.Header, but the chapters under the unit is again a list. I tried like below but chapters are not able to view on UI.

XAML

<StackLayout BindableLayout.ItemsSource="{Binding  AllItems,Mode=TwoWay}">
    <BindableLayout.ItemTemplate>
        <DataTemplate>
            <Expander
                ExpandAnimationEasing="{x:Static Easing.CubicIn}"
                ExpandAnimationLength="500"
                CollapseAnimationEasing="{x:Static Easing.CubicOut}"
                CollapseAnimationLength="500">
                <Expander.Header>
                    <StackLayout
                        Orientation="Horizontal">

                        <Label 
                            Text="{Binding unit.title}"
                            TextColor="Black"
                            HorizontalOptions="Start" 
                            HorizontalTextAlignment="Start"
                            FontSize="18"
                            VerticalTextAlignment="Center"
                            VerticalOptions="CenterAndExpand">
                        </Label>
                    </StackLayout>
                </Expander.Header>
                <Expander.ContentTemplate>
                    <DataTemplate>
                        <StackLayout 
                            Orientation="Horizontal">

                            <Label
                                HorizontalOptions="Start"
                                Text="{Binding contentList.title}"
                                VerticalOptions="CenterAndExpand"
                                FontSize="16"
                                TextColor="Black">
                            </Label>
                        </StackLayout>
                    </DataTemplate>
                </Expander.ContentTemplate>
            </Expander>
        </DataTemplate>
    </BindableLayout.ItemTemplate>
</StackLayout>

My JSON Data format:

"bookContentList": [
        {
            "unit": {
                "title": "Unit 1: Revelation"
            },
            "contentList": [
                {
                    "title": "Unit 1: Preview",
                    "embedCode": "c1"
                },
                {
                    "title": "Chapter 1: God&#39;s Plan for all creation",
                    "embedCode": "c2"
                },
                {
                    "title": "Chapter 2: Made to be with god",
                    "embedCode": "c3"
                },
                {
                    "title": "Chapter 3: Signs of gods presence",
                    "embedCode": "c4"
                }
            ]
        },
        {
            "unit": {
                "title": "Unit 2: Trinity"
            },
            "contentList": [
                {
                    "title": "Unit 2: Preview",
                    "embedCode": "c5"
                },
                {
                    "title": "Chapter 4: The mystery of the trinity",
                    "embedCode": "c6"
                },
                {
                    "title": "Chapter 5: Prayer and Worship",
                    "embedCode": "c7"
                },
                {
                    "title": "Chapter 6: Life of Virtue",
                    "embedCode": "c8"
                }
            ]
        }
    ]

ViewModel

private List<BookContentList> _allItems;
public List<BookContentList> AllItems
{
    get
    { return _allItems; }
    set
    {
        _allItems = value;
        OnPropertyChanged("AllItems");
    }
}
//setting data
AllItems = bookDetails.bookContentList;

My problem is chapters under each unit is not showing on the UI. I have uploaded a sample project here for the easy reference.

Also, I need to know how to get the complete details of the selected chapter?

How to bind collection view selected items into a new listview using MVVM?

$
0
0

I have the following observableCollection:
Main View Model:

MainViewModel : INotifyProperyChanged
 public MainViewModel()
{
Accessories = new ObservableCollection<string>();
            Accessories.Add("Cast");
              Accessories.Add("Neck Ring");
             Accessories.Add("Shoulder Wedges");
            Accessories.Add("Grip Rings");
            Accessories.Add("Head Rest");
            Accessories.Add("Knee Roll");
            Accessories.Add("Elbow Sling");
             Accessories.Add("Thermoplastic Mask");
            Accessories.Add("Vacuum Lock Bags");
            Accessories.Add("Breast Board");
}

 public ObservableCollection<string> selectedAccessories = new ObservableCollection<string>();
        public ObservableCollection<string> SelectedAccessories
        {
            get => selectedAccessories;
            set
            {
                if (selectedAccessories == value)
                    return;
                else
                {
                    selectedAccessories = value;
                    OnPropertyChanged(nameof(SelectedAccessories));

                }
            }
public event PropertyChangedEventHandler PropertyChanged;
         public void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

Then on the XAML Side:

    <CollectionView ItemsSource="{Binding Accessories}" SelectionMode="Multiple" SelectedItems="{Binding SelectedAccessories}" />

    <Label x:Name="label1" Text="{Binding SelectedAccessories}"  />

    <ListView x:Name="list1" ItemsSource="{Binding SelectedAccessories}"  />

I would like to display in either a label or listview (both work). Now, Selected Accessories is an observable collection that would need to be the ItemsSource for the new list.

I also tried a different PropertyChanged method and it still doesn't work:

public event PropertyChangedEventHandler PropertyChanged;
        publicvoid OnPropertyChanged2(ObservableCollection<string> selectedAccessories)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(selectedAccessories.ToString()));
        }

The same structure work for other data types but I can't make it work for ObservableCollections. Do I need to create a method to retrieve the strings of the selected items? How can I access the selectedItems?


Xamarin forms broadcast reciever

$
0
0

Hi guys,
I have a problem with my app. As I have authorization (username/password), and when I login in the application, and click the Lock button on my phone, my app logs out. Now I want the same thing, when i put my app in the background, and THEN I click lock button (now nothing happens, when I go back, user is logged in). I found something with the broadcast receiver, but I'm not able to figure it out
`

         [BroadcastReceiver(Enabled = true)]

            [IntentFilter(new[] { Android.Content.Intent.ActionScreenOff })]

            public class MySampleBroadcastReceiver : BroadcastReceiver

            {

                public override void OnReceive(Context context, Intent intent)

                {

                    switch (intent.Action)

                    {

                        case Intent.ActionScreenOff:

                            //My method for loging out user
                            break;

                    }
                }
            }

`
I'm not sure how to call this broadcast receiver, when app is in background and I'm locking the phone.
I hope someone can help me :)

class property not initialize for Xamarin form cross platform only for IOS

$
0
0

I am using Xamarin Cross Platform application to build a sample login form. The following code is just taking the email and password value and giving result. The unique problem is when i run this for Android emulator everything is working fine. The class object LoginDTO hold the value of Username , password but when i run the code for IOS the username ,password is not holding the value and after explicit assign it showing null.

I don't know what is wrong here. I appreciate your help.

                LoginDTO objLogin = new LoginDTO();
                objLogin.UserName = email;
                objLogin.Password = password;
                UserManagerService umanager = new UserManagerService();
                blnresult = await umanager.ValidateLogin(objLogin);

trying to get value from entry column from a xamarin.forms.datagrid

$
0
0

hi guys
im trying to get the quantity value that is set when i enter it.
i cannot use ant third-party licenses such as synfusion, telerik,etc.
i have to use this datagrid

is there any way for me to obtain a value from a cell...?

How to establish button click in code behind

$
0
0

Hello,
I have created a form with grid which contains button and label.So the number or rows and columns vary according to my table.
i haved binded label and button text. now when i click a button i want the data which is binded to that clicked button.
Since number of rows and columns vary i have done this in code behind.Please help

<List> table=new <List>();
protected async override void OnAppearing()
        {
            //data for table is getting using webapi. im not giving that code
            count= table.Count;
            decimal rw = (decimal)table.Count / 3;
            decimal  RowCountRequired = Decimal.Ceiling(rw);
            var maxwidth = Application.Current.MainPage.Width;
            var width = maxwidth / 3;

            for (int currentRow = 0; currentRow < RowCountRequired; currentRow++)
            {
                count = count - ColumnCountRequired;
                for (int currentColumn = 0; currentColumn < ColumnCountRequired; currentColumn++)
                {
                        var label = new Label
                        {

                            HorizontalTextAlignment = TextAlignment.Center,
                            VerticalTextAlignment = TextAlignment.Center
                        };
                        label.SetBinding(Label.TextProperty, nameof(Table_Master.th_tableid));
                        gridLayout.Children.Add(label, currentColumn, currentRow);
                }
            }
            ColumnCountRequired = 3;
            count = table.Count;
            for (int currentRow = 0; currentRow < RowCountRequired; currentRow++)
            {
                gridLayout.RowDefinitions.Add(new RowDefinition { Height = 250});
                gridLayout.VerticalOptions = LayoutOptions.FillAndExpand;
                gridLayout.HorizontalOptions = LayoutOptions.FillAndExpand;
                if (count < 3)
                {
                    ColumnCountRequired =  count;
                } 
                count = count - ColumnCountRequired;
                for (int currentColumn = 0; currentColumn < ColumnCountRequired; currentColumn++)
                {
                    gridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width =width});
                    Button button = new Button
                    {
                        TextColor=Color.White,
                        BackgroundColor = Color.Green,
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.FillAndExpand,


                    };

                    button.SetBinding(Label.TextProperty, nameof(Table_Master.th_tablename));
                    button.Clicked += OnButtonClicked;
                    gridLayout.Children.Add(button    , currentColumn, currentRow);

                }

                // reduce the number of columns on the next row to simulate row span       
                // ColumnCountRequired = ColumnCountRequired - 1;

            }

            for (int i=0;i<table.Count; i++)
            {
                gridLayout.Children[i].BindingContext = table[i];
            }

                base.OnAppearing();
        }


private void OnButtonClicked(object sender, EventArgs e)
        {

// if i click row0,col0 th button i want data binded to label o ro0,col0
        }

App Crashed After Xamarin Forms Update to 4.7.0.968

How do reload page when click item menu in Xamarin.Form Shell Flyout

$
0
0

I'm using the Xamarin.Form Shell Flyout.

When click item menu, from the second time, the page don't reload.

How do reload page (reload data) when click item menu in Xamarin.Form Shell Flyout?

 <FlyoutItem Route="animals" Title="Animals" FlyoutDisplayOptions="AsMultipleItems">
            <ShellContent Route="Monkeys" Title="Monkeys" Icon="tab_feed.png" ContentTemplate="{DataTemplate local:MonkeysPage}"
 <FlyoutItem/>

My app is unable to connect to internet when I publish app to app store.

$
0
0

My app is unable to connect to internet when I publish app to app store. But it is working when I install using AdHoc profile. Please find below for my info.plist

<key>App Transport Security Settings</key>
<dict>
    <key>Allow Arbitrary Loads</key>
    <true/>
</dict>
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>subdomain.domain.com</key>
        <dict>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

please let me know an doing any mistake. my domain uses "https"


Linker Issue

$
0
0

Hey there,

I'm just wondering if anyone can help me out here.
I am trying to use the linker to reduce the size of my apk.
I have gotten a few errors and resolved them by adding the assemblies to my linker.config file in my Android project.

I am getting the below error:
Mono.Linker.MarkException: Error processing method: 'System.Security.Claims.ClaimsPrincipal IdentityServer4.IdentityServerPrincipal::Create(System.String,System.String,System.String,System.Collections.Generic.IEnumerable`1<System.String>,System.DateTime,System.Security.Claims.Claim[])' in assembly: 'IdentityServer4.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Int32 IdentityModel.EpochTimeExtensions::ToEpochTime(System.DateTime) at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference) at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference) at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction) at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body) at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method) at Mono.Linker.Steps.MarkStep.ProcessQueue() --- End of inner exception stack trace --- at Mono.Linker.Steps.MarkStep.ProcessQueue() at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue() at Mono.Linker.Steps.MarkStep.Process() at Mono.Linker.Steps.MarkStep.Process(LinkContext context) at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context) at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step) at Mono.Linker.Pipeline.Process(LinkContext context) at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context) at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res) at Xamarin.Android.Tasks.LinkAssemblies.RunTask() at Xamarin.Android.Tasks.AndroidTask.Execute()

-I have added IdentityServer4 to my linker.config file but it hasn't resolved the issue.
-I have cleaned and rebuilt my solution approx 4 billion times as I've seen that has resolved similar issues for other people.
-All my nuget packages are up to date.
-If I set linker to None, it works but my apk is about 110MB.

Thanks in advance,
Shane

Xamarin.Forms tiled background image?

$
0
0

I've seen a few old threads about tiled backgrounds, but they're either abandoned with no answer or they were not about Xamarin.Forms specifically, but about how to implement tiled backgrounds on each platform.

I'm guessing this is still not possible on Xamarin.Forms, or am I wrong? Anyone knows?

How to change bottom navigation bar icon color Xamarin forms ios

$
0
0

In my project i added bottom navigation bar but i facing an issue unable to change default icon selection colors.

Tabbed page renderer written like this

protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
    base.OnElementChanged(e);
    UITextAttributes normalTextAttributes = new UITextAttributes();
    normalTextAttributes.Font = UIFont.FromName("SanFranciscoText-Light", 9.0F); // unselected

    TabBar.TintColor = UIKit.UIColor.FromRGB(153, 67, 2);
    TabBar.BarTintColor = UIColor.FromRGB(223, 139, 75); 
    try
    {
        var tabbarController = (UITabBarController)this.ViewController;
        if (null != tabbarController)
        {
            tabbarController.ViewControllerSelected += OnTabbarControllerItemSelected;
        }
    }
    catch (Exception exception)
    {
        Console.WriteLine(exception);
    }
    UITabBarItem.Appearance.SetTitleTextAttributes(normalTextAttributes, UIControlState.Normal);
}


public override UIViewController SelectedViewCont
{
    get
    {
        UITextAttributes selectedTextAttributes = new UITextAttributes();
        selectedTextAttributes.Font = UIFont.FromName("SanFranciscoText-Bold ", 12.0F); // SELECTED
        selectedTextAttributes.TextColor = UIColor.White;
        return base.SelectedViewController;
    }
    set
    {
        allViewControllers = base.ViewControllers.ToList();
        base.SelectedViewController = value;
        foreach (UIViewController viewController in base.ViewControllers)
        {
            UITextAttributes normalTextAttributes = new UITextAttributes();
            normalTextAttributes.Font = UIFont.FromName("SanFranciscoText-Light ", 9.0F); 
            viewController.TabBarItem.SetTitleTextAttributes(normalTextAttributes, UIControlState.Normal);
        }           
    }
}

I want to change selected tab Icon color to dark orange and unselected tab color to white. Is there any way to do this ?

Thanks,
Jagdeesh.

FirebaseInstanceId.Instance.Token returning null

$
0
0

In My app, I am trying to get FirebaseInstanceId.Instance.Token but it returning null

Firebase.FirebaseApp.InitializeApp(this);
LoadApplication(new App());
var token = FirebaseInstanceId.Instance.Token;

showing error

java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process music.com.wiltapplication. Make sure to call FirebaseApp.initializeApp(Context) first

Is there any mistaken in my code ?

Thanks,
Jagdeesh

Styling ViewCell.ContextActions MenuItem

$
0
0

Hi,
I am looking for some guide that help me to change the style of Viewcell menuitem

Thankou in advance,
David.

Viewing all 91519 articles
Browse latest View live