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

How to Create Multiple Tabs In a Single Screen Xamarin forms

$
0
0

I am Trying to create a UI Like https://youtube.com/watch?v=LrOR5QOCHBI.

In Android What i can do is:
Go to Resources->Layout->Tabber.axml and set app:tabMode="scrollable" and create a tabbed page and play with costume renders.

Problem:
1) In IOS is the top-bar is not scowling ( I did used a plugin to make Tabbed Page on top in IOS) it shows More instead of scrolling.
2) How would i link a list-view or any other view with tabbed pages.


Socket Closed error

$
0
0

Hi,

I'm developing an application with Xamarin Forms 2.3.4.247, Prism 6.3.0 and the CrossConnectivity Plugin for Xamarin.

My application does a lot of http requests, and every time I make one I do this check.
CrossConnectivity.Current.IsConnected
and then
CrossConnectivity.Current.IsRemoteReachable(url)

but sometimes when later executing my http requests to the same URL, I get the error Socket Closed

I'm using System.Net.HttpClient for http requests. The error is random and happens with various hosts. I haven't been able to reproduce the error at will, it occurs erratically.

Is there any way of finding the cause of this error? Does anybody know how to fix it?

What are Available Designing tools for Xamarin forms

$
0
0

Please suggest availble tools for xamarin forms UI designing ...

How to hide all the icons in the media player other than Play/Pause and Volume button?

$
0
0

I have a media player in which I want to hide the aspect ratio, cast to device and full screen icon in media player. This is the screenshot of my media player in which I have marked the icon which I need to hide in red color.

So I have taken this media player from https://github.com/inthehand/InTheHand.Forms . This is the my Xaml code

<StackLayout>
        <Button Text="Stretch" Clicked="Button_Clicked"/>
        <forms1:MediaElement HorizontalOptions="Fill"  BackgroundColor="Green" VerticalOptions="Center" HeightRequest="180" x:Name="Media" IsLooping="True"   AreTransportControlsEnabled="true" Source="http://video.ch9.ms/ch9/334f/891b78a5-642d-40b4-8d02-ff40ffdd334f/LoginToLinkedinUSingXamarinAuth_mid.mp4"/>
    </StackLayout>

This is my media element code-

public sealed class MediaElement : View
    {
        /// <summary>
        /// Identifies the AreTransportControlsEnabled dependency property.
        /// </summary>
        public static readonly BindableProperty AreTransportControlsEnabledProperty =
          BindableProperty.Create(nameof(AreTransportControlsEnabled), typeof(bool), typeof(MediaElement), false);

        /// <summary>
        /// Identifies the AutoPlay dependency property.
        /// </summary>
        public static readonly BindableProperty AutoPlayProperty =
          BindableProperty.Create(nameof(AutoPlay), typeof(bool), typeof(MediaElement), true);

        /// <summary>
        /// Identifies the BufferingProgress dependency property.
        /// </summary>
        public static readonly BindableProperty BufferingProgressProperty =
          BindableProperty.Create(nameof(BufferingProgress), typeof(double), typeof(MediaElement), 0.0);

        /// <summary>
        /// Identifies the IsLooping dependency property.
        /// </summary>
        public static readonly BindableProperty IsLoopingProperty =
          BindableProperty.Create(nameof(IsLooping), typeof(bool), typeof(MediaElement), false);

        /// <summary>
        /// Identifies the KeepScreenOn dependency property.
        /// </summary>
        public static readonly BindableProperty KeepScreenOnProperty =
          BindableProperty.Create(nameof(KeepScreenOn), typeof(bool), typeof(MediaElement), false);

        /// <summary>
        /// Identifies the Source dependency property.
        /// </summary>
        public static readonly BindableProperty SourceProperty =
          BindableProperty.Create(nameof(Source), typeof(Uri), typeof(MediaElement));

        /// <summary>
        /// Identifies the CurrentState dependency property.
        /// </summary>
        public static readonly BindableProperty CurrentStateProperty =
          BindableProperty.Create(nameof(CurrentState), typeof(MediaElementState), typeof(MediaElement), MediaElementState.Closed);

        /// <summary>
        /// Identifies the Position dependency property.
        /// </summary>
        public static readonly BindableProperty PositionProperty =
          BindableProperty.Create(nameof(Position), typeof(TimeSpan), typeof(MediaElement), TimeSpan.Zero, validateValue: ValidatePosition);

        private static bool ValidatePosition(BindableObject bindable, object value)
        {
            MediaElement element = bindable as MediaElement;
            if (element != null)
            {
                if (element._renderer != null)
                {
                    element._renderer.Seek((TimeSpan)value);
                }
            }

            return true;
        }

        /// <summary>
        /// Identifies the Stretch dependency property.
        /// </summary>
        public static readonly BindableProperty StretchProperty =
          BindableProperty.Create(nameof(Stretch), typeof(Stretch), typeof(MediaElement), Stretch.Uniform);



        private IMediaElementRenderer _renderer = null;

         public void SetRenderer(IMediaElementRenderer renderer)
        {
            _renderer = renderer;
        }


        /// <summary>
        /// Gets or sets a value that determines whether the standard transport controls are enabled.
        /// </summary>
        public bool AreTransportControlsEnabled
        {
            get { return (bool)GetValue(AreTransportControlsEnabledProperty); }
            set { SetValue(AreTransportControlsEnabledProperty, value); }
        }

        /// <summary>
        /// Gets or sets a value that indicates whether media will begin playback automatically when the <see cref="Source"/> property is set.
        /// </summary>
        public bool AutoPlay
        {
            get { return (bool)GetValue(AutoPlayProperty); }
            set { SetValue(AutoPlayProperty, value); }
        }

        /// <summary>
        /// Gets a value that indicates the current buffering progress.
        /// </summary>
        /// <value>The amount of buffering that is completed for media content.
        /// The value ranges from 0 to 1. 
        /// Multiply by 100 to obtain a percentage.</value>
        public double BufferingProgress
        {
            get
            {
                return (double)GetValue(BufferingProgressProperty);
            }
        }

        /// <summary>
        /// Gets or sets a value that describes whether the media source currently loaded in the media engine should automatically set the position to the media start after reaching its end.
        /// </summary>
        public bool IsLooping
        {
            get { return (bool)GetValue(IsLoopingProperty); }
            set { SetValue(IsLoopingProperty, value); }
        }

        /// <summary>
        /// Gets or sets a value that specifies whether the control should stop the screen from timing out when playing media.
        /// </summary>
        public bool KeepScreenOn
        {
            get { return (bool)GetValue(KeepScreenOnProperty); }
            set { SetValue(KeepScreenOnProperty, value); }
        }

        public TimeSpan NaturalDuration
        {
            get
            {
                if (_renderer != null)
                {
                    return _renderer.NaturalDuration;
                }

                return TimeSpan.Zero;
            }
        }

        public int NaturalVideoHeight
        {
            get
            {
                if (_renderer != null)
                {
                    return _renderer.NaturalVideoHeight;
                }

                return 0;
            }
        }

        public int NaturalVideoWidth
        {
            get
            {
                if (_renderer != null)
                {
                    return _renderer.NaturalVideoWidth;
                }

                return 0;
            }
        }

        /// <summary>
        /// Gets or sets a media source on the MediaElement.
        /// </summary>
        [TypeConverter(typeof(Xamarin.Forms.UriTypeConverter))]
        public Uri Source
        {
            get { return (Uri)GetValue(SourceProperty); }
            set { SetValue(SourceProperty, value); }
        }

        private IDictionary<string, string> _httpHeaders = new Dictionary<string, string>();
        public IDictionary<string, string> HttpHeaders
        {
            get
            {
                return _httpHeaders;
            }
        }

        /// <summary>
        /// Gets the status of this MediaElement.
        /// </summary>
        public MediaElementState CurrentState
        {
            get { return (MediaElementState)GetValue(CurrentStateProperty); }
            internal set
            {
                SetValue(CurrentStateProperty, value);
            }
        }

        public void RaiseCurrentStateChanged()
        {
            CurrentStateChanged?.Invoke(this, EventArgs.Empty);
        }

        /// <summary>
        /// Gets or sets the current position of progress through the media's playback time.
        /// </summary>
        public System.TimeSpan Position
        {
            get
            {
                if (_renderer != null)
                {
                    return _renderer.Position;
                }

                return (TimeSpan)GetValue(PositionProperty);
            }

            set
            {
                SetValue(PositionProperty, value);
            }
        }

        /// <summary>
        /// Plays media from the current position.
        /// </summary>
        public void Play()
        {
            CurrentState = MediaElementState.Playing;
        }

        /// <summary>
        /// Pauses media at the current position.
        /// </summary>
        public void Pause()
        {
            if (CurrentState == MediaElementState.Playing)
            {
                CurrentState = MediaElementState.Paused;
            }
        }

        /// <summary>
        /// Stops and resets media to be played from the beginning.
        /// </summary>
        public void Stop()
        {
            if (CurrentState != MediaElementState.Stopped)
            {
                CurrentState = MediaElementState.Stopped;
            }
        }

        /// <summary>
        /// Gets or sets a value that describes how an MediaElement should be stretched to fill the destination rectangle.
        /// </summary>
        /// <value>A value of the <see cref="Stretch"/> enumeration that specifies how the source visual media is rendered.
        /// The default value is Uniform.</value>
        public Stretch Stretch
        {
            get
            {
                return (Stretch)GetValue(StretchProperty);
            }

            set
            {
                SetValue(StretchProperty, value);
            }
        }

        /// <summary>
        /// Occurs when the value of the <see cref="CurrentState"/> property changes.
        /// </summary>
        public event EventHandler CurrentStateChanged;

        /// <summary>
        /// Occurs when the MediaElement finishes playing audio or video.
        /// </summary>
        public event EventHandler MediaEnded;

        public void RaiseMediaOpened()
        {
            MediaOpened?.Invoke(this, EventArgs.Empty);
        }

        /// <summary>
        /// Occurs when the media stream has been validated and opened, and the file headers have been read.
        /// </summary>
        public event EventHandler MediaOpened;

        public void RaiseSeekCompleted()
        {
            SeekCompleted?.Invoke(this, EventArgs.Empty);
        }

        /// <summary>
        /// Occurs when the seek point of a requested seek operation is ready for playback.
        /// </summary>
        public event EventHandler SeekCompleted;

        public void OnMediaEnded()
        {
            CurrentState = MediaElementState.Stopped;

            if (MediaEnded != null)
            {
                System.Diagnostics.Debug.WriteLine("Media Ended");
                MediaEnded(this, EventArgs.Empty);
            }
        }

        internal void RaisePropertyChanged(string propertyName)
        {
            OnPropertyChanged(propertyName);
        }
    }

    public interface IMediaElementRenderer
    {
        double BufferingProgress { get; }

        TimeSpan NaturalDuration { get; }

        int NaturalVideoHeight { get; }

        int NaturalVideoWidth { get; }

        TimeSpan Position { get; }

        void Seek(TimeSpan time);
    }
}

I don't have any clue how hide those icons. Any suggestions?

How to fix White Screen Issue while navigating in Xamarin forms Prism MasterDetails Page?

$
0
0

I have implemented MasterDetail Page using xamarin forms prism and I have following Pages in my app.
1) Master
2) Home
3) Employee
4) Profile

-- Initially App is set to Master - Home (Detail Page) page after login. From Home page i navigate to Employee (Detail Page) using code as follows :

await _navigationService.NavigateAsync("NavigationPage/Employee");

-- From Employee Page I navigate to Profile (Content Page - Non Detail page) by clicking on one of the employees using code:

await _navigationService.NavigateAsync("Profile", lstparam, null, false);

-- Once home button is clicked in profile page, i want to navigate to Master - Home (Detail Page) . However it navigates to Employee (Detail Page) .

await _navigationService.GoBackToRootAsync();

Checked navigation stack by debugging , It was only showing Employee (Detail Page) Page in it. Also tried navigation to home page by using following code :

await NavigationService.NavigateAsync("/Master/NavigationPage/Home");

The above code is working and i can navigate to Home (Detail Page) , but I am getting White Screen while navigating to Profile to Home Page .

Attached Screenshots . Please Help .Thanks in Advance.

1)Master

2)Home

3)Employee

4)Profile

5) file:///C:/Users/tkanekar/Desktop/Forum/Whitescreen.png

Xamarin form : Cannot access a disposed object : Xamarin.Forms.Platform.Android.FormsTextView

$
0
0

I have a list view contains image (FF Image Loading) and some labels. When i run my app it crashes meanwhile i've been using caching strategy : "RecycleElement" on list to prevent crash but it throws exception "Cannot access a disposed object : 'Xamarin.Forms.Platform.Android.FormsTextView'".
Anyone has solved similar problem?

Dear Xamarin users, I am facing the below error. Has anyone of you have faced similar kind of issue?

$
0
0

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

02-12 14:23:21.930 E/mono (11007): Unhandled Exception:
02-12 14:23:21.930 E/mono (11007): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Type not found in cache: TimeFlow.App.Services.IWifiService.
02-12 14:23:21.930 E/mono (11007): at GalaSoft.MvvmLight.Ioc.SimpleIoc.DoGetService (System.Type serviceType, System.String key, System.Boolean cache) [0x0003f] in C:\Users\lbugn\Documents\MVVMLight\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Extras (PCL)\Ioc\SimpleIoc.cs:589
02-12 14:23:21.930 E/mono (11007): at GalaSoft.MvvmLight.Ioc.SimpleIoc.GetService (System.Type serviceType) [0x00000] in C:\Users\lbugn\Documents\MVVMLight\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Extras (PCL)\Ioc\SimpleIoc.cs:872
02-12 14:23:21.930 E/mono (11007): at GalaSoft.MvvmLight.Ioc.SimpleIoc.MakeInstance[TClass] () [0x00064] in C:\Users\lbugn\Documents\MVVMLight\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Extras (PCL)\Ioc\SimpleIoc.cs:800
referenceTable GDEF length=814 1
referenceTable GSUB length=11364 1
referenceTable GPOS length=47302 1
referenceTable head length=54 1
referenceTable GDEF length=808 1
referenceTable GSUB length=11364 1
referenceTable GPOS length=49128 1
referenceTable head length=54 102-12 14:23:21.930 E/mono (11007): at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)

Xamrin Forms CarouselView with GridLayout Collection?

$
0
0

Given a collection of items - how would one implement a grid layout like so:

(from https://github.com/pauldipietro/CollectionViewSample)
... but instead of the list scrolling vertically down - create a new carousel page to scroll horizontally?

Will the new XF4 controls cater for this scenario?


Problem facing while changing the orientation of master detail page.

$
0
0

Hi, I am developing a xamarin forms app.
I want my Master(Menu List) page of MasterDetailPage to be open both in landscape and portrait mode once it gets fired.
It should be open untill user intetionally hide it by sliding it back.
Currnetly Master page is getting hide while coming from landscape to portrait mode and vice versa.Kindly help me out.

How to access path of external SD CARD using xamarin.forms

$
0
0

Unhandled Exception: System.UnauthorizedAccessException: occurred when i am trying to access path given below:
content://com.android.externalstorage.documents/tree/13E7-3B0A%3AMyZip

APK Update

$
0
0

Hi All,

I am going to generate new APK and trig to install in my phone. but problem is there is already install that application and again I am install with new version but it was not update exiting app.!

Mobile Advertising Platform

$
0
0

Hi,

I am not sure what's the exact name of it, Platform or Portal or something else..

What I want to ask here is..

When Google Ads shows ads for all publishers on my app, is there any services which allows me to have a platform where I can show only customers who wants to show their ads on my app without having to show others app?

So basically, customer will pay me and I place the ads on my app.

Anyone uses such solution...

Thanks,
Jassim

HttpClient in php login Form (methode GET)

$
0
0

I want code a App who login to a Web Service on PHP with Xamarin.Forms. Do you can me help me with the C# code?

OCR

$
0
0

Anyone have success with any OCR tools?

ContentPage.ToolbarItems and NavigationPage.TitleView with UWP project

$
0
0

When I use NavigationPage.TitleView block to set a page title, my toolbar icons in ContentPage.ToolbarItems block are pushed to the Secondary menu. This happens only with UWP project while the Android project behaves as expected.

If, however, I move the UWP ToolBar to the bottom in the Application wide App.xaml.cs with the following

MainPage.On<Windows>().SetToolbarPlacement(ToolbarPlacement.Bottom);

it works as expected, except that the top Toolbar is still there as a blank. However, for consistency, I would like the ToolBar to remain in the Top.

Are NavigationPage.TitleView and ContentPage.ToolbarItems mutually exclusive for UWP project, or am I missing something such as disabling some of the UWP features such as its native CommandBar control?

PS: XF is ver 3.4.0.1008975


Better to use XAML or code to layout UI?

$
0
0

I am just starting out, I downloaded free book on Xamarin.Forms by Charles Petzold

His book just seems to only use code to layout. I admit it is a little hard to follow the code,
although coding the layout can be very verbose (possibly more options), I just wonder if doing things in XAML would be better way to go?

Thanks

An Android app remembers its data after uninstall and reinstall

$
0
0

Hi ,

Im' using plugin settings to save user Pin so when he open again the app so he will auto login .

My problem here is when I unistall the application and install it again , it does not start from zero , but there is a saved login , I know that android from

version 6 , have a func that auto backup , so I added to my manifest file those 2 lines but it didn't work . any idea ?

  <application android:allowBackup="false"/>
<application 
    android:fullBackupContent="false">
</application>

How To Keep Track when background services are executing/executed

$
0
0

Iam new to Xamarin, what I am trying to close that gap on a pattern used for messages. How do pages/view models know if a background service sent a message before that viewmodel was instantiated? How do I know if a background service IS running or just finished running a few mins ago or did the background service fail?

Scenario:
User on a Login Page logs in. We start a few background services

Download latest list of pdf files
Pull list of products available
Download a bunch of images
etc...
the the UI will open the persons' profile page and subscribe to each of the events and display data from the database once completed. In the navigation menu you can go to the products available page, when that pages loads I shows you all products available. How does the ProductsAvailableViewModel know if all products were downloaded, or did it fail to download. The message could have been sent prior to the viewmodel object instantiation.

I was thinking of solving the problem this way
1. Have a table in the SQLlite database that tracks all the messages sent by all services. A view model can query the events to see if a service is still working on pulling data, or if it recently failed and needs to be retried before showing any data on the screen.
OR
2. Having a "manager for each BG processor. That will start the BG process throughh a message and subscribe to the events of the BG Process and keeping the states in the "Manager" object. when going to sleep save state info in the Application.Current.Properties. Using Unity I will only have one instance of each object which then viewmodels/views can check info based on their needs

Is there a common pattern practice that is being used out there? I don't want to fall into some anti-pattern process which will have to be re-written.

Xamarin Camera

$
0
0

Hi, i wanna show the camera on xaml file, for example in stacklayout, but i can´t find an example. The only examples are about how to display de camera device.

Dynamically Updating Bluetooth Device Picker

$
0
0

Hi,

I am trying to get a picker that will dynamically update as soon as it detects a new, compatible Bluetooth device and add it to the end of the picker list, while the picker is open.

Currently I am binding the ItemsSource to a list of available devices and this produces the list I want when clicking on the picker. However, if a new device comes into range while the picker dialogue box is open, then the device will not appear in the picker until I close the picker dialogue and reopen. The same should also happen in reverse, so if a device goes out of range, it should be removed from the picker options.

Furthermore, I would also like the picker to automatically select the first index in the ItemsSource, when one becomes available.

Currently I am calling the following when the screen appears:

devicePicker.ItemDisplayBinding = new Binding("DeviceName");
devicePicker.ItemsSource = App.bluetoothLib.AvailableDevices;
App.bluetoothLib.ScanForDevices();

And the devices are then added using AvailableDevices.Add({}); within the BLE handlers.

Thanks in advance

Viewing all 91519 articles
Browse latest View live


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