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

The first tab is not visible in the Sharpnado.Presentation.Forms tab structure.

$
0
0

Hi everyone !

I am using the Sharpnado.Presentation.Forms nuget package. They have very beautiful tab structures. Everything works fine, but the first tab does not appear automatically when the page is first displayed. I need to tapped the tab for the **ContentView ** inside the tab to appear.

How can i solve It?

<tabs:TabHostView x:Name="TabHost"
                          Grid.Row="1"
                          TabType="Scrollable"
                          BackgroundColor="White"                          
                          SelectedIndex="{Binding Source={x:Reference Switcher}, Path=SelectedIndex, Mode=TwoWay}"
                          ShadowType="Bottom">

            <tabs:TabHostView.Tabs>
                <tabs:UnderlinedTabItem Style="{StaticResource TabStyle}"
                                        IsSelected="True"
                                        Label="General"/>

                <tabs:UnderlinedTabItem Style="{StaticResource TabStyle}"  
                                        Label="Contacts" />

                <tabs:UnderlinedTabItem Style="{StaticResource TabStyle}"
                                        Label="Team" />

                <tabs:UnderlinedTabItem Style="{StaticResource TabStyle}"
                                        Label="Billing Info" />

                <tabs:UnderlinedTabItem Style="{StaticResource TabStyle}" 
                                        Label="Other" />
            </tabs:TabHostView.Tabs>
        </tabs:TabHostView>

        <ScrollView Grid.Row="2" Margin="0,3,0,0">
            <tabs:ViewSwitcher x:Name="Switcher"
                               SelectedIndex="{Binding SelectedViewModelIndex, Mode=TwoWay}"
                               Animate="True">
                <details:ExpenseDetailPage BindingContext="ExpenseDetailPage" Animate="True"/>
                <details:ExpenseDetailPage BindingContext="ExpenseDetailPage" Animate="True"/>
                <details:ExpenseDetailPage BindingContext="ExpenseDetailPage" Animate="True"/>
                <details:ExpenseDetailPage BindingContext="ExpenseDetailPage" Animate="True"/>
            </tabs:ViewSwitcher>
        </ScrollView>

Thanks in advance !


Does custom renderer control inherit Base properties?

$
0
0

Hello,

I am using https://github.com/XamFormsExtended/Xfx.Controls "Custom entry control". I am trying to set MaxLength and IsReadOnly properties of entry on "Custom entry control" but those properties are not active on control and I ain't getting desired result.
How can function those base properties to work with custom renderer?

Question about menus and corners

$
0
0
Hey. Please tell me how to make the same panel with such angles?

View disappeared while adding list view item dynamically

$
0
0

i have created view using custom rendered, and added it in list view item template. the view appear only at load time, if i tried to add new item old items get disappeared. it worked well in X.F version 3.6.0.344, after update with latest it not worked,

`var width = RootLayout.MeasuredWidth; //rootlayout is relative layout.
var height = RootLayout.MeasuredHeight;

AvailableSize = new System.Drawing.Size(width, height);`

used above code to set desired size for view. while dynamic update width and height became "0" after updated with 4.4 and above version.

i have attach my sample, please suggest solution. is this any breaking changes.

image 1: from XF version - 3.6.0344

image 2: XF version <4.4......

How To Complete LayoutRoot Children Updates Before Display

$
0
0

I have created a sizable master layout controller in code that manipulates the XAML of numerous ContentPages. The controller does four different things for all pages other than the main screen

  1. Determines the sizing of the page grids (columns and rows), child UI elements and fonts to be used based on the device and applies the values so there is a common look and feel
  2. Creates a master page header
  3. Translates the page text to the language of the user
  4. Determines the word wrapping based on the language and font to be shown

Until recently everything was working fine. However, I just completed a major redesign and update of other processes that the application has, primarily initialization. One of the update factors was performance improvement. It appears that in the previous version, those processes sufficiently delayed the finalization of a page that the changes made by the controller to the UI elements where completed before the page displayed. I have written code to test the scenario where the page is displayed, but the size of a element is changed after the page is displayed with no impact on the screen elements themselves. I have gone as far as setting the LayoutRoot in the XAML to not visible and resetting it to visible after a ForceLayout with about the same results.

How can I control when the actual page display occurs based on finalization of the UI element changes?

Unable to write on SD card

$
0
0

Hi,

I can't write or simply move a file stored on SD card. I have no exceptions

  • reading/writing files on the phone storage
  • reading files on the SD card

Certainly the permssions are present in the AndroidManifest.xml file

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

and they are given during runtime.

So everytime I try to write on SD card a "System.UnauthorizedAccessException: Access to the path is denied." is thrown.
You can reproduce it with this simple code

            void MoveFile(string path)
            {
                string newpath = path + ".mp3";

                System.IO.File.Move(path, newpath);

                Console.WriteLine("----------------- File moved! ------------------".ToUpper());
            }

Right after the System.IO.File.Move(path, newpath); statement is thrown a System.UnauthorizedAccessException.

Responsive Font Size for different devices

$
0
0

I'm trying to deal with different devices and platforms (Android & iOS) without success.

I subclassed Label and calculate font size with Device.GetNamedSize and multiplying it by factor (also tried without it). But it does not look well in all devices, but no success.

Was looking XLab project and thought that I could categorize devices (like it is done with resources [HDPI,XHDPI,...]) but I couldn't find a way to calculate the device display size in inches.

Is there a better way to face this issue? Thanks in advance.

How do I solve the Unable to figure out route for: // in Xamarin Shell Flyout menuItems?

$
0
0

I have created the Flyout menuItems below. In this particular order.

                         <FlyoutItem Shell.TabBarIsVisible="False" Route="header"  FlyoutDisplayOptions="AsMultipleItems">
            <ShellContent x:Name="BookItItem" Route="bookit" Title="BOOK IT" ContentTemplate="{DataTemplate views:HomePage}" />
            <ShellContent x:Name="ExploreItem" Route="explore" Title="EXPLORE" ContentTemplate="{DataTemplate subs:ExplorePage}" />
            <ShellContent x:Name="ContactItem" Route="contact" Title="CONTACT" ContentTemplate="{DataTemplate login:ContactPage}" />
        </FlyoutItem>

         <FlyoutItem Shell.TabBarIsVisible="False" Route="main" FlyoutDisplayOptions="AsMultipleItems">
            <ShellContent x:Name="MyReservationsItem" Route="reservation" Title="MY RESERVATIONS" ContentTemplate="{DataTemplate            reservations:MyReservationsPage}" />
            <ShellContent x:Name="MyGuestItem" Route="guest" Title="MY GUESTS" ContentTemplate="{DataTemplate guests:MyGuestsPage}" />
            <ShellContent x:Name="OverViewItem" Route="account" Title="OVERVIEW"  Icon="" ContentTemplate="{DataTemplate settings:OverViewPage}" />
            <ShellContent x:Name="PasswordSecurityItem" Route="password"  Title="PASSWORD &amp; SECURITY" ContentTemplate="{DataTemplate settings:PasswordSecurityPage}" />
            <ShellContent x:Name="EmailPreferencesItem" Route="email" Title="EMAIL PREFERENCES" ContentTemplate="{DataTemplate settings:EmailPreferencesPage}"  />
        </FlyoutItem>

However, the requirement based on certain conditions, is for the landing page to be the ExplorePage.

In the AppShell I have set it like so.

        public AppShell(string pageName)
                {
                    InitializeComponent();
                     Routing.RegisterRoute("explore", typeof(ExplorePage));
                          if( pageName == “explore”)
                          {
                              this.CurrentItem = this.Items[0].Items[1];
                                      this.CurrentItem.Style = (Style)this.Resources[“MainShell"];
                                      ExploreItem.SetValue(FlyoutBackgroundColorProperty, Color.Blue);
                          }
                }

It lands on that page, the FlyoutBackgroundColor does not change to blue, meaning it doesn’t highlight the row on the flyout menu item list.
When I click on the same Explore MenuItem, it throws an exception.
Error Message : Unable to figure out route for: //

I set the FlyoutDisplayOptionsProperty to "AsMultipleItems" to group the items such that the separator separates the groups.

I added the
Routing.RegisterRoute("explore", typeof(ExplorePage)); to the constructor with the hope that would resolve the problem but it hasn't.

How do I solve this problem?
Unable to figure out route for: //


How can we compare two image source ??

$
0
0

I have a image control in collection view & source of image is embeded .So Question comes here that I want to compare the image source of collection view with other image source which has also embeded source to check whether both the image is same or not if same the change image in collection view ;
Here The code which i tried but wont work Both of the image is same thoug byte is different;

   ImageSource What = ImageSource.FromResource("schoolproject.AttendanceIcon.What.png");
   ///////TapGestureRecognizer in collection View////////////
    private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
    {
        var Sender = sender as Image;
        var attend = Sender.BindingContext as Attendance;
      ///Now converting the image coming from view into stream////////////////
        StreamImageSource st = (StreamImageSource)Sender.Source;
        System.Threading.CancellationToken cancellationToken = System.Threading.CancellationToken.None;
        Task<Stream> TASK = st.Stream(cancellationToken);
        Stream stream = TASK.Result;
        byte[] ImageSrcFromView = ReadFully(stream);///////stream in to byte

       ////Convert the image into stream which i want to compare///////
        StreamImageSource whatimg = (StreamImageSource)What;
        System.Threading.CancellationToken whatcancellationToken = System.Threading.CancellationToken.None;
        Task<Stream> whatTASK = whatimg.Stream(whatcancellationToken);
        Stream whatstream = whatTASK.Result;
        byte[] whatImageSrcFromView = ReadFully(whatstream);//////stream into byte

       ///Finally i am comparing the byte of both image which is same but value is false i don"t know why?//////
        if(ImageSrcFromView == whatImageSrcFromView)
        {
            Sender.Source = Present;
        }
  }

public static byte[] ReadFully(Stream input)
{
using(MemoryStream ms = new MemoryStream())
{
input.CopyTo(ms);
return ms.ToArray();
}
}

Unable to select/copy/paste text in Xamarin.Forms Editor or custom Borderless Editor using renderer

$
0
0

Hello @JamesMontemagno ,

I've implemented Borderless Editor in my Xamarin.Forms application using Custom EditorRenderer. But I'm facing an issue that the editor text is not selectable at all in both cases, neither in Forms editor control nor in Rendered native editor control. My app has the functionality to let user copy paste the text in the editor while typing, like in any other text editing app. This is a basic feature in most of the apps and is by default there. But it's not working in my app. I've tried enabling it through

Control.SetTextIsSelectable(true);

but still it's not working. I've tried other things too, like:

Control.CustomSelectionActionModeCallback = new CustomSelectionActionModeCallback(); Control.CustomInsertionActionModeCallback = new CustomInsertionActionModeCallback();

But nothing is working at all and text is not getting selected even a single word. Does anyone has any idea about this issue? How can I make the text selectable and allow default copy paste feature in custom editor?

Thanks in advance !

Display placeholder image when image does not load of UriImageSource

$
0
0

Hi

I am using a remote uri as a source for an Image in Xamarin forms using a UriImageSource. I want to display a placeholder image/control when the remote image does not exist, but cant find a nice way to do this. I thought IsLoading might be the one but this is set to false once it succeeds or fails to load the image, do I have test if the remote image exists, seems a little over kill making another Http request just to determine if it doesn't exists and show a placeholder?

thanks

How to add custom fonts on xamarin forms

$
0
0

Hello,

I work on a project xamarin forms, and i want to add a new font family.
i followed the official tutorial and it's not working!
i downloaded a font fantasy.ttf and then i paste it in asset of android project then i added this code in app.xaml


this don't work.
(#Final Fantasy i finded it in properties of the Fantasy.tff file in title)

How can i solve this?
thanks!

creating a menu on a content page

$
0
0

i would like to add a menu to the following content page:

public class MyPage: ContentPage
{
//othe vars
public MyPage()
{
Title = "My Page";
Content = new StackLayout
{
Children =
{
webView
}//children
};//content
}

// other code.....

}

I think I can build the menu by adding menu items. But I do not see how to attach to menu to this page.
How can I do this?

Android service close if app closes

$
0
0

hi guys i'm trying to do an android service for my app and i'm facing this issue, i've been looking for information about it and found that i need to use StartCommandResult.Sticky option for the service to not get closed, but it is not working here's the piece of code i'm using:

    protected override StartCommandResult onStartCommand(Intent intent, StartCommandFlags flags, int startId){
        var t = new Task(() => {

            DoServiceWork();
        });

        t.Start();

        return StartCommandResult.Sticky;
    }

and this is how i've been calling it in my activity

protected override void OnCreate(Bundle bundle){
    new Task(StartService).Start();
}

void StartService(){
    var intent = new Intent(Application.Context, typeof(MyService));
    Application.Context.StartService(intent);
}

but didin't work =(
can anyone help me, for you guys to know i've been trying things the whole day believe me

InsertAsync Xamarin Invalid data type provided

$
0
0

I have a problem with the InsertAsync function. I hope I'm not disturbing. The object I'm trying to insert is called User, it has 3 properties Id, username & password. When I call the InsertAsync() method (without giving any id and having the ID autoincrement on and IDENTITY_INSERT OFF) it throws an invalid data type provided error. If I delete the identity on id and I set an id value from the code it works. But I want it to work with the autoincrement method. Thank you!


How can I run a certain job in background even though after I close my app?

$
0
0

I am creating a mobile app for employee to check in. After check in, I want their location can be keep tracked all the time like 30 minutes interval. In the other words, every 30 minutes, the location of the mobile phone will be sent to the server through calling a WebService. It is impossible for me to ask them open the mobile app and screen all day long right? So I want to have a background process that will run inside the mobile phone? How can I achieve that? The concept is just like the alarm in the mobile phone, how it knows when to ring everyday even though the user does not open the alarm app? I have tried alarmManager but unfortunately nothing works. Thanks in advance.

is it possible to implement NFC in xamarin forms?

$
0
0

I have been trying with sample plugin but i am not able to figure out how to implement NFC read/Write for Android/iOS using a plugin.if it is possible share some sample code which would help me

How to set the web view size to fit the content size?

$
0
0

I'm using the WebView control to display an html link and use a custom webview render class to allow zooming in/out. However, when the page is displayed, the content is really small while there are a lot of space around it. This happens to both Android and iOS. I tried to modify the custom webview render class to fit the content but had no success. Could you please help me to resolve this issue? Thanks a lot.

Here is my code and the screenshot:

For the shared project:
namespace Project1
{
public class ReportPage : ContentPage
{
public ReportPage ()
{
Title = "Report Page";

                Content = new WebView
                {
                    Source = "--mywebpagehere--"                
                };
    }
}

}

For the webview render in android:

[assembly: ExportRenderer(typeof(WebView), typeof(CustomWebViewRenderer))]

namespace Project1.Droid
{
class CustomWebViewRenderer: WebViewRenderer
{
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);

        if (Control != null)
        {
            Control.Settings.BuiltInZoomControls = true;
            Control.Settings.DisplayZoomControls = false;

            Control.Settings.LoadWithOverviewMode = true;
            Control.Settings.UseWideViewPort = true;
        } 
    }
}

}

For the webview render in iOS:

[assembly: ExportRenderer(typeof(WebView), typeof(CustomWebViewRendererIOS))]

namespace QSRMovel.iOS
{
class CustomWebViewRendererIOS : WebViewRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
this.ScalesPageToFit = true;
this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
}
}
}

Xamarin Forms and Azure - Easy table gone

$
0
0

Hi,
Need help and advice. Last month, my Azure resources removed for some unknown reason and Microsoft were not able to explain what happened.

Anyway, We got everything back but the app cannot communicate with SQL server. We checked everything and all is fine except one issue!
I initially used Easy Table that made it so easy to setup Mobile App on Azure platform. Microsoft removed Easy Table and it is not accessible. I cannot find any new documentation to explain how to resolve it. I don't have experience in node.js.

When I use postman to test the connection and data, I get the following error message:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Has anyone experienced it? Any solution?

Thank you for your help in advance.

Kind regards,
Kamal

Why Xamarin.Auth to make Facebook login doesn't return the email?

$
0
0

I'm trying to make a Facebook Login using Xamarin.Auth, it works returning the id and name but does not returns email even adding fields in url.

How do I to return email ?

Trying

using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Android.App;
using Xamarin.Auth;
using Newtonsoft.Json.Linq;
using PremiosOnApp.View;

[assembly: ExportRenderer(typeof(LoginFacebookView), typeof(PremiosOnApp.Droid.FBLoginPageRenderer))]

namespace PremiosOnApp.Droid
{
    public class FBLoginPageRenderer : PageRenderer 
    {
        public FBLoginPageRenderer()
        {
            var activity = this.Context as Activity;

            var auth = new OAuth2Authenticator(
                clientId: "2955384417913313", 
                scope: "", 
                authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"),
                redirectUrl: new Uri("http://www.facebook.com/connect/login_success.html"));

            auth.Completed += async (sender, eventArgs) => {
                if (eventArgs.IsAuthenticated)
                {
                    var accessToken = eventArgs.Account.Properties["access_token"].ToString();
                    var expiresIn = Convert.ToDouble(eventArgs.Account.Properties["expires_in"]);
                    var expiryDate = DateTime.Now + TimeSpan.FromSeconds(expiresIn);

                    var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=email"), null, eventArgs.Account);
                    var response = await request.GetResponseAsync();

                    Console.WriteLine(response.GetResponseText());

                    //var obj = JObject.Parse(response.GetResponseText());

                    //var id = obj["id"].ToString().Replace("\"", "");
                    //var name = obj["name"].ToString().Replace("\"", "");
                    //var email = obj["email"].ToString().Replace("\"", "");

                    // Console.WriteLine("Nome: " + name + ", email: " + email);

                    //await App.NavigateToProfile(string.Format("Olá {0}, seja bem-vindo", name));
                }
                else
                {
                    //await App.NavigateToProfile("O usuário Cancelou o login");
                }
            };

            activity.StartActivity(auth.GetUI(activity));
        }
    }
}
Viewing all 89864 articles
Browse latest View live


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