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

Xamarin.forms UI with Relative Layout

$
0
0

<?xml version="1.0" encoding="UTF-8"?>




            RowHeight="120"
            HasUnevenRows="true"
            BackgroundColor="White"
            SeparatorColor="White"

            VerticalOptions="Start">
          <ListView.ItemTemplate>
            <DataTemplate>
              <ViewCell>
          <RelativeLayout
            HorizontalOptions="FillAndExpand"
            VerticalOptions="Center"
            BackgroundColor="#494949">
            <Image
            WidthRequest="500"
            Aspect = "AspectFill"
            AbsoluteLayout.LayoutBounds="0,0,1,1"
            Source="{Binding Cover.Source}"
            Opacity="0.5"/>

            <StackLayout
            Orientation="Horizontal"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand"
            BackgroundColor="Transparent"
            Padding="15"
            RelativeLayout.XConstraint=
                            "{ConstraintExpression Type=Constant,
                                                    Constant=0}"
              RelativeLayout.YConstraint=
                            "{ConstraintExpression Type=Constant,
                                                    Constant=0}"
              RelativeLayout.WidthConstraint=
                            "{ConstraintExpression Type=RelativeToParent,
                                                    Property=Width,
                                                    Factor=1}"
                        >
                        <StackLayout

                            WidthRequest="60"
                            HeightRequest="60"


                            >
                             <RelativeLayout


                            >

                            <Image
                            WidthRequest="60"
                            HeightRequest="60"
                            Source="Background_c"
                            />
                            <Label

              TextColor="White"
              HorizontalOptions="Center"
                XAlign="Center"
                YAlign="Center"

              FontAttributes="Bold"
              FontSize="18"
              RelativeLayout.XConstraint=
                          "{ConstraintExpression Type=RelativeToParent,
                                              Property=Width,
                                              Factor=1,
                                              Constant=0}"
                      RelativeLayout.YConstraint=
                          "{ConstraintExpression Type=Constant,
                                                  Constant=0}"

              />
                            <Label
              Text="{Binding DateEvent}"
              TextColor="White"
              HorizontalOptions="Center"
                XAlign="Center"
                YAlign="Center"
                WidthRequest="70"
              FontAttributes="Bold"
              FontSize="14"

              RelativeLayout.XConstraint=
                          "{ConstraintExpression Type=RelativeToParent,
                                              Property=Width,
                                              Factor=1,
                                              Constant=-65}"
                      RelativeLayout.YConstraint=
                          "{ConstraintExpression Type=Constant,
                                                  Constant=15}"/>


                            </RelativeLayout>

                            </StackLayout>

              <StackLayout

                Spacing="0"
                            >
                <Label
                  Text="{Binding Name}"
                  TextColor="White"
                  HorizontalOptions="FillAndExpand"
                  HeightRequest="25"
                  FontAttributes="Bold"
                  FontSize="17"/>
                <StackLayout
                  Orientation="Horizontal"
                  Spacing="10"
                  HeightRequest="25">
                  <Label
                    Text="{Binding WeekDay}"
                    TextColor="White"
                    FontSize="17"/>
                  <Label
                    Text="{Binding DateEvent}"
                    TextColor="White"
                    FontSize="17"/>
                </StackLayout>
                <StackLayout
                  Orientation="Horizontal"
                  VerticalOptions="FillAndExpand"
                  Spacing="10"
                  HeightRequest="20"
                                >
                  <Label
                    Text="Sted:"
                    TextColor="White"
                    FontSize="14"
                    VerticalOptions="Center"/>
                  <Label
                    Text="{Binding Location}"
                    TextColor="White"
                    FontSize="14"
                    VerticalOptions="Center"/>
                </StackLayout>
              </StackLayout>
            </StackLayout>
                   <Image
                          Source="Arrow-1"
                          WidthRequest="30"
                          HeightRequest="30"
                          VerticalOptions="Center"
                          HorizontalOptions="Center"
                          RelativeLayout.XConstraint=
                              "{ConstraintExpression Type=RelativeToParent,
                                                  Property=Width,
                                                  Factor=1,
                                                  Constant=-25}"
                          RelativeLayout.YConstraint=
                              "{ConstraintExpression Type=Constant,
                                                      Constant=57}"
                      />
          </RelativeLayout>

               </ViewCell>
            </DataTemplate>
          </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</StackLayout>


Custom Timepicker, Focus() not working

$
0
0

Hi!

I implemented following solution stack answer to create a 24H timepicker in Xamarin, the problem with this solution is that the Focus() method to trigger the picker does not function on Android. If I remove the custom renderer, the Focus() works again on Android.

Is this a bug, or am I doing something wrong?

Thanks

Xamarin forms: Change color of app navigation bar button item after completion of bacground task

$
0
0

I have a functionality in my Xamarin form based application where I am working on sync task, I want to show the user the current progress of the sync throughout the application in the application navigation bar.

Irrespective of whatever view the user is currently seeing if the background sync activity is completed the navigation bar button icon should change from yellow to green indicating that the sync is completed and if it fails it should change from yellow to red.

My application is currently being worked for UWP and in future it will support for iOS and Android, first I would like to know if this kind of feature is doable or not in Xamarin forms, if its doable I would like to know the steps.

My Solution: As of now I have shown a modal view on the tap of navigation bar button, the modal view has a progress bar which shows the status of the background sync using events and delegates pattern, but my client wants to change the color of the navigation bar button rather than displaying another modal view.

Requesting you to provide guidance on the same.

css path doesnt work on device, but on simulator

$
0
0

Hi!

We are having a big problem with our iOS app that we built with xamarin forms, the app is caching a html and a css script to the device, which then is being rendered for the user to see.
We are using xlabs hybridwebview. The problem is that while running the app on an iOS device (iPad) the webview only renders the html and does not load the css file, or at least the css is not being rendered. But if we run the app in the simulator the css is being rendered.

This line of code calls a method that returns the path, this path is used to save a folder containing an html file and a css file:
var path = Path.Combine(DependencyService.Get<IFileHelper>().GetDocumentsFolderPath(), form.id.ToString()) + "/";

Note: we have tried without the ending slash but no difference.

This is the method that returns the path to the css file, it works on the simulator but not on the device:

public string GetDocumentsFolderPath()
        {
            return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
        }

This is how we load the hybridwebview

protected override void OnAppearing()
        {
        var path = Path.Combine(DependencyService.Get<IFileHelper>().GetDocumentsFolderPath(), form.id.ToString()) + "/";
        var html = we read the html from the path as a stream (this works);
        webview.LoadContent(html, path);
    }

Xamarin Forms Backgrounding

$
0
0

I create a tracking application but i have problem with backgrounding on iOS (android works with messaging center)

First i use messaging center from this blog
http://arteksoftware.com/backgrounding-with-xamarin-forms/

next i try override the PerformFetch and add here the service call (i get user location and post it to service)

example:

UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval (UIApplication.BackgroundFetchIntervalMinimum);

    public override async void PerformFetch (UIApplication application, Action<UIBackgroundFetchResult> completionHandler)
    {
            var downloadSuccessful = false;
            try {
                Manager.StartLocationUpdates (dbid, route);
                downloadSuccessful = true;
            } catch (Exception ex) {
                downloadSuccessful = false;
            }

            if (downloadSuccessful) {
                completionHandler (UIBackgroundFetchResult.NewData);
            } else {
                completionHandler (UIBackgroundFetchResult.Failed);
            }
    }

public void StartLocationUpdates (int userid, int route)
    {
        if (CLLocationManager.LocationServicesEnabled) {


            LocMgr.DesiredAccuracy = 3;
            LocMgr.StartUpdatingLocation ();


            Console.WriteLine ("Altitude: " + LocMgr.Location.Altitude + " meters");
            Console.WriteLine ("Longitude: " + LocMgr.Location.Coordinate.Longitude);
            Console.WriteLine ("Latitude: " + LocMgr.Location.Coordinate.Latitude);
            Console.WriteLine ("Course: " + LocMgr.Location.Course);
            Console.WriteLine ("Speed: " + LocMgr.Location.Speed);

            Console.WriteLine("<---Location Updated--->");

            service.SetUserData (userid, LocMgr.Location.Coordinate.Longitude, LocMgr.Location.Coordinate.Latitude, route, service.GetToken());

            LocMgr.StopUpdatingLocation ();

        }
    }

This codes run only on emulators (Run-> Simulate iOS Background Fetch), i wait a lot time but nothing happened.

more info (info.plist):

Enable Background Modes
1)Location Updates
2)Background Fetch

Location Always Usage Description

  • All device setting is enabled.

All methods where i use works perfect on emulators (front and background), what can i do for iOS ?

Thanks

How to create circular progress bar in xamarian.forms ?

$
0
0

On Button click event how to create circular progress bar, can any one give me little bit hint so can i resolve the problem...#Thanks

check if has network connection

$
0
0

Hi I'm trying find out if there is a way to check the device has a network connection from the App.cs file and not individually for each device.

Does anyone know

thanks

How do I display a file in iOS with a WebView?

$
0
0

Background:
We have an app that accesses a web site using a WebView. The user can download an attachment from the web site. Once the file is downloaded a alert pops up to tell the user the file is downloaded and ready to be opened. I am using an interface and a platform specific implementation to download and save the file.

Problem:
I am not sure how to get the device to show the file using the default app for iOS.

Code:

public interface IDownloadHelper{
    void StartDownload(string url);

}

public class DownloadHelper : IDownloadHelper{

    public void StartDownload(string url)
    {
        //download file and save it.

        Device.BeginInvokeOnMainThread(() => {
            var alert = new UIAlertView("Done", "File has been downloaded", null, "open", null);
            alert.Clicked += (s, args) => {
                OpenFile(fileName, filePath);
            }
            alert.Show();
        });
        //the rest of the download code is here
    }

    public void OpenFile(string fileName, string filePath)
    {

        //this is where I am a little lost, I am not sure if this is the best way to do this or not.
        var webView = new UIWebView();
        string localDoc = Path.Combine(NSBundle.mainBundle.BundlePath, fileName);
        webView.LoadRequest(New NSUrlRequest(new NSUrl(localDoc, false)));
        webView.ScalesPageToFit = true;

        //I am not sure how to push this onto the View stack

    }

}

Question about creating xaml forms

$
0
0

i have a project lets say called App1 and App1.Droid. I want to create a new xamarin xaml file that as both the xaml file and the cs file. I can only do that in the App1 project and not in the App1.Droid project. In the App1 project i right click on the project and then select Add -> New Item and under Cross Platform i select Forms.Xaml.Page. What if i want the xaml page inside the Droid project. Maybe in a Xamarin.Forms i want the forms to look differently depending on the mobile platform. how do i create a xaml page that has both a xaml page and a cs page inside the Droid project?

Xamarine Update Error

$
0
0

Hi,

I am getting below error while updating Xamarin.Android libraries.

Severity Code Description Project File Line Suppression State
Error Unable to resolve dependencies. 'Xamarin.Android.Support.v7.CardView 23.4.0-beta1' is not compatible with 'Xamarin.Forms 2.2.0.16-pre3 constraint: Xamarin.Android.Support.v7.CardView (= 23.3.0)'. 0

Kindly Help me to resolve this error

Thanks in advance.
Satish

having a xamarin.forms app without creating one

$
0
0

i want the advantage of a xamarin.forms project but i am only developing for the android so i dont really need the sharing of code etc. Can i create a blank android app and add the forms dll and still get the benefits of forms but without the multiple projects and shared code project?

Mvvm framework without page navigation

$
0
0

I'm quite new to mvvm and therefore I'd like some advice on which mvvm framework would be a "best fit" for the following scenario.

I will be developing an app that will look almost exactly the same on each platform. The general idea is that the application will have one page consisting of a header, footer and content in between. My navigation would not be pushing and popping pages but instead it would just change the content between the header and the footer.
The reason for this is that I dont want to reload the header/footer every time.

So now I have taken a look at the (many) mvvm frameworks out there and I have noticed that they all assume that the navigation is done from page to page.

Do you know of any framework that would allow me to do this custom "View" navigation?

How to upload file to server with HTTP POST multipart/form-data in xamarin portable

$
0
0

Hi Friends, please help on this.

How to create Check box group, radio button group and multi line text box

$
0
0

Hi,

Can any one suggest me to create Checkbox group, radio button group and multi line text box in xamarin forms?

How to efficiently handle icons with switching between light and dark themes?

$
0
0

I will probably allow users to switch my app's colors, whether by using themes or otherwise.

At the moment, my icons are designed to work on a light colored background, so typically have dark pixels with transparent cells around them.
When the user switches the theme to a dark background, I either need my icons to adapt (although I suspect that would be horribly slow) or to switch to a second set of icons that use light colored pixels with transparent cells around them.

What method have people found of doing this efficiently, ideally using binding, but ideally not overlaying two images and switching IsVisible (I don't want the overhead of loading two of every image if the user never changes colors) ?


Can't get started with Xamarin in .NET 2015

$
0
0

Hi there guys,

Today i wanted to start exploring the beautiful world of Xamarin development. I installed the package, opened a new blank app for Android and then a screen pops up. 'Get started with Xamarin'. I assumed this wasn't too important, closed to page and opened the Main Activity c# file. I tried to run it, to see what happends but i get a warning. "There were deployment errors. Continue?". I use the latest Xamarin and Visual Studio distributions. What causes this? I also do not see the App Designer view that other sources show. Does anyone have an idea?

Thanks in advance!

Kind regards,

Stephen

Add different code for different platform in Forms

$
0
0

Hi,

I worked on Xamarin Forms application,

As per my application requirement I need to manage different customisation for each platform.

For example, If i want to set different background image for each platform how can manage this ?

if iPad

        this.BackgroundImage = "Bg.jpg";

endif

if iPhone

        this.BackgroundImage = "Bg1.jpg";

endif

if Android Tablet

        this.BackgroundImage = "Bg2.jpg";

endif

if Android Phone

        this.BackgroundImage = "Bg3.jpg";

endif

if watchos

        this.BackgroundImage = "Bg4.jpg";

endif

What are the correct Xamarin.Forms.Keyboard mappings for a custom renderer?

$
0
0

Or better yet, is there a method in Xamarin.Forms that'll set it for me?

Here's what I have so far, but I know I'm way off, and don't support KeyboardFlags, which I'd like to be able to.

Droid

private void SetKeyboard()
{
    if (Element.Keyboard == Keyboard.Url)
    {
        NativeView.EditText.InputType = InputTypes.ClassText | InputTypes.TextVariationUri;
    }
    else if (Element.Keyboard == Keyboard.Email)
    {
        NativeView.EditText.InputType = InputTypes.ClassText | InputTypes.TextVariationEmailAddress;
    }
    else if (Element.Keyboard == Keyboard.Numeric)
    {
        NativeView.EditText.InputType = InputTypes.ClassNumber;
    }
    else if (Element.Keyboard == Keyboard.Chat)
    {
        NativeView.EditText.InputType = InputTypes.ClassText | InputTypes.TextVariationShortMessage;
    }
    else if (Element.Keyboard == Keyboard.Telephone)
    {
        NativeView.EditText.InputType = InputTypes.ClassPhone;
    }
    else if (Element.Keyboard == Keyboard.Text)
    {
        NativeView.EditText.InputType = InputTypes.ClassText | InputTypes.TextFlagNoSuggestions;
    }
}

Touch

private void SetKeyboard()
{
    if (Element.Keyboard == Keyboard.Chat)
    {
        NativeView.KeyboardType = UIKeyboardType.Twitter;
    }
    else if (Element.Keyboard == Keyboard.Text)
    {
        NativeView.KeyboardType = UIKeyboardType.ASCIICapable;
    }
    else if (Element.Keyboard == Keyboard.Numeric)
    {
        NativeView.KeyboardType = UIKeyboardType.NumberPad;
    }
    else if (Element.Keyboard == Keyboard.Telephone)
    {
        NativeView.KeyboardType = UIKeyboardType.PhonePad;
    }
    else if (Element.Keyboard == Keyboard.Url)
    {
        NativeView.KeyboardType = UIKeyboardType.Url;
    }
    else if (Element.Keyboard == Keyboard.Email)
    {
        NativeView.KeyboardType = UIKeyboardType.EmailAddress;
    }
}

Entry that displays Popup/Dialog on focus

$
0
0

Hi, new to Xamarin. I would like to create a custom control that, when it receives focus, displays a popup/dialog. The popup/dialog would contain an Entry control and possibly a couple of buttons at the top, with a scrollable list view below them. So, similar to a Picker, but the popup would contain more than just a scrollable list. Being new to Xamarin, I'm not quite sure how to proceed in creating such a control. Has anyone seen something like this, or can give me some guidance in the right direction? Thanks.

navigation within uiviewcontroller

$
0
0

I am trying to merge the function from this tutorial (https://developer.xamarin.com/recipes/ios/media/video_and_photos/choose_a_photo_from_the_gallery/) into my application and currently I put the code within the FinishedLaunching (https://github.com/xamarin/recipes/blob/master/ios/media/video_and_photos/choose_a_photo_from_the_gallery/AppDelegate.cs) into ViewDidLoad inside of a custom renderer

  1. I don't know other way lunching the image picker viewcontroller besides putting it into a custom page renderer (viewdidload), is there another way?

  2. within Handle_Canceled, the desired feature is closing down the gallery modal and navigate to a content page, I have been looking around, but did not manage to find the navigation resource within UIViewController, please help!

Viewing all 58056 articles
Browse latest View live


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