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

Gradient as background color

$
0
0

I want to set a gradient background to a Xamarin.Forms layout and view. How can i do that?

A tricky but not very appealing is using a WebView and settings the gradient background using CSS but i want to avoid this.

I already searched the forum but didn't found anything, sorry if i missed something.


Can ListView ContextActions behave similarly across all platforms?

$
0
0

Specifically, I want to use the swipe left gesture that is used for Context Actions in iOS. I don't like that in Android, you need to do a long press and the context actions appear on the toolbar.. and on Universal Windows, you have to do a right click and a plain menu shows up.

I think swipe left (or right) has been adopted for most touch based lists now, and I'd like this to be consistent across all platforms for my app.

Can this be done if I am using Xamarin.Forms ListView?

Issue with BaseUrl in WebView

$
0
0

So i'm having issues with stylesheets and images using a WebView.

Here is what i do:

  • I POST to an URL and download the response html
  • I add this to HtmlWebViewSource(), which i then add to a WebView
  • I then set my BaseUrl to the domain
  • No profit...

Here are some code snippets:

string raw_html = getHtml();
WebView browser = new WebView();

>

HtmlWebViewSource html = new HtmlWebViewSource {
Html = raw_html
};

html.BaseUrl = getBaseUrl(); // i have tried with many different urls here (to make sure the path is not the problem) however none seems to work
browser.Source = html;

Custom Grid Not Normal work

$
0
0

I have a custom grid named EasyTabView.
use xaml:

<local:EasyTabView>
        <local:EasyTabView.TabHeaders>
            <Label Margin="8" Text="Header1" VerticalOptions="Center" HorizontalOptions="Center">
            </Label>
            <Label Text="Header2" VerticalOptions="Center" HorizontalOptions="Center">
            </Label>
        </local:EasyTabView.TabHeaders>
        <local:EasyTabView.TabContents>
            <ContentView>
                <Label Margin="8" Text="Content1" VerticalOptions="Center" HorizontalOptions="Center">
            </Label>
            </ContentView>
            <ContentView>
            <Label Text="Content2" VerticalOptions="Center" HorizontalOptions="Center">
            </Label>
            </ContentView>

        </local:EasyTabView.TabContents>
    </local:EasyTabView>

grid define code:
```C#
foreach (var tabHeader in TabHeaders)
{
ColumnDefinitions.Add(new ColumnDefinition()
{
Width = GridLength.Star
});
}

        RowDefinitions = new RowDefinitionCollection() {
            //头
            new RowDefinition()
            {
                Height = GridLength.Auto
            },
            //指示标示
            new RowDefinition()
            {
                Height = IndicatorHeight
            },
            //内容
            new RowDefinition()
            {
                Height = GridLength.Star
            }

        };

        this.BatchBegin();
        // 设置TabHeaders 显示
        for (int i = 0; i < TabHeaders.Count; i++)
        {
            //SetRow(TabHeaders[i], 0);
            //SetColumn(TabHeaders[i], i);
            Children.Add(TabHeaders[i], i, 0);
        }
        //设置指示器
        var indicatorView = new BoxView();
        indicatorView.Color = SelectedColor;
        Children.Add(indicatorView, SelectedIndex, 1);
        //设置TabContents 显示
        for (int i = 0; i < TabContents.Count; i++)
        {
            TabContents[i].IsVisible = SelectedIndex == i;
            Children.Add(TabContents[i], 0, TabContents.Count, 2, 3);
        }
        this.BatchCommit();

```

But there's a problem right now,the Grid not display the child first.When the second show,the child just show and Multiple the child while repeat add.i try call the InvalidateLayout() method No effect。who can help me。

Decode .tiff file and draw image based on path of svg data

$
0
0

I have a .tif file and I want to decode it and draw an image on canvas based on path data of svg.

I googled for a whole day and every site shows how to show existing svg image but I want to draw image from data we get in path element .

it will be best if I can decode .tiff file but I have ready svg path data as shown in below link.

Something like this.

I think in WPF there is <Path> element and we can specify data in <Path.Data>. Is it possible in xamarin.forms ?

Thank you.

Setting delegate of control in custom renderer results in lost functionality

$
0
0

I am trying to make a custom ListView that can track where the list is in the view.
To do this I need to set the delegate of the control, but if I do this I loose original functionality (Like ItemSelected).

I guess that Xamarin have made a delegate for the ListView and I am setting my CustomListView to a new delegate, but I can't "get" a delegate from control.delegate.

Should I override Xamarins delegate or how can I do this?

My CustomListView Renderer

public class CustomListViewRenderer : ListViewRenderer, IUITableViewDelegate, IUIScrollViewDelegate
{
    CustomListView list;

    protected override void OnElementChanged (ElementChangedEventArgs<ListView> e)
    {
        base.OnElementChanged (e);

        if (list == null)
            list = this.Element as CustomListView;

        Control.WeakDelegate = this;
    }

    [Export ("scrollViewDidScroll:")]
    public void Scrolled (UIKit.UIScrollView scrollView)
    {
        System.Diagnostics.Debug.WriteLine (scrollView.ContentOffset.Y.ToString());
    }
}

Xamarin Forms Maps problem on Android when IsShowingUser = true

$
0
0

I have recently tried to add xamarin.forms.maps to an application. iOS took about 20 minutes. Android, of course, is the problem.

I think I've got the API key specified correctly, restricted as it ought to be, in the Manifest, etc.

    <application android:icon="@drawable/ic_launcher" android:debuggable="false" android:theme="@style/MyTheme" android:label="MOVE C&amp;V">
        <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyB608Ert10EN_pJDlJuGSAhvQDnotreal" />
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    </application>

I'm getting an error as soon as I try to bring up the page with the map in it.

I just noticed (after typing all this out) that it only happens if IsShowingUser = true. When I set that value to false in the XAML, things work JUST FINE (all caps for the stay up past midnight for bs problem).

There are some errors in the application output that I thought were the source of the problem. Namely

Rejecting re-init on previously-failed class java.lang.Class<mi>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/chimera/Fragment;

and

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.chimera.Fragment"

XAML for the map page is pretty simple as well.

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
    x:Class="AppNamespace.MapPage"
    >


    <ContentPage.Padding>
        <OnPlatform x:TypeArguments="Thickness">
            <OnPlatform.iOS>0, 20, 0, 0</OnPlatform.iOS>
            <OnPlatform.Android>0, 0, 0, 0</OnPlatform.Android>
            <OnPlatform.WinPhone>0, 0, 0, 0</OnPlatform.WinPhone>
        </OnPlatform>
    </ContentPage.Padding>


    <ContentPage.Content>
        <StackLayout
            VerticalOptions="FillAndExpand"
            Padding="10"
            Orientation="Vertical"
            BackgroundColor="{DynamicResource Background}"
            >
            <maps:Map
                x:Name="mapControl"
                IsShowingUser="true"
                MapType="Street"
                VerticalOptions="FillAndExpand"
            />

            <StackLayout
                Orientation="Horizontal"
                x:Name="stackBack"
                BackgroundColor="White"
                Padding="10,10,10,10"
                Margin="0,10,0,10"
                VerticalOptions="End"
                >

                <Label
                    x:Name="lblBack"
                    Text="Back"
                    HorizontalOptions="CenterAndExpand"
                    TextColor="{DynamicResource Blue}"
                    FontSize="22"
                    VerticalOptions="Center"
                    FontAttributes="Bold"
                />

                <Image
                    x:Name="imgBack"
                    Source="{DynamicResource BackArrow}"
                    WidthRequest="50"
                    HeightRequest="50"
                />

            </StackLayout>

        </StackLayout>
    </ContentPage.Content>
</ContentPage>

Any help at all is much appreciated.

Estimote SDK for Android , does it work for you ?

$
0
0

Hello guys, i wonder if any of you have managed to make an estimote app that can detect beacons on android/ forms . I have tried using the Xamarin Estimote SDK for android, but never managed to go beyond the ready state for the manager. Did anyone succeed to get some results ?


PDF Webview works great, but how about handeling annotation events?

$
0
0

The following article works great for a PDF viewer in Xamarin Forms. https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/controls/display-pdf/

My PDF's have URL Link annotations, and I would like to capture the link activation and pop up a little text screen when selected which includes a link to another area of the app. Any samples on this anywhere? I have been coming up empty. I am tempted to convert the PDF to images and have hotspots on the images that I can capture the event handlers programmatically perhaps... any examples on that option as well?

I looked at the PDFViewer control by Syncfusion, but they do not have annotation support yet.

IOS option in Target platform section is grey and not clickable

$
0
0

I tried to install Xamarin Automatically on my mac. But the download failed again and again. SO I had to download all files manually then install it. I downloaded Xamarin.Android and Xamarin.Ios with others and installed it. But The Ios part is not working..

Do I need to install Xcode before doing it?

I tried to auto update from xamarin ide too. But it also failed at 60%.

Using FAB.forms ?

$
0
0

I am trying to add a Flating Action Button to a simple listview using FAB.forms but nothing is appearing & there are no build errors.

I have added FAB.forms v2.1.1 to a XAmarin Forms PCL project and also added Xamarin.Android.Support.Design to Android Packages.

Following the provided guides I have constructed my XAML page as follows

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:FABTest"
             xmlns:fab="clr-namespace:FAB.Forms;assembly=FAB.Forms"
             x:Class="FABTest.Contacts" >
  <ContentPage.Content>
        <RelativeLayout>
            <ContentView
                RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=10}"
                RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=10}">
    <ListView x:Name="EndpointListView" ItemsSource="{Binding Items}" IsVisible="{Binding IsListVisible}" HasUnevenRows="True" SeparatorColor="{DynamicResource ListViewSeparatorColor}" >
      <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <Label Text="{Binding Name}" />
            </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
  </ContentView>
            <fab:FloatingActionButton
                x:Name="fabBtn"
                Source="plus.png"
                Size="Normal"
                Clicked="Handle_FabClicked"
                NormalColor="Green"
                RippleColor="Red"
                RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=-50}"
                RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=-50}" />
        </RelativeLayout>
    </ContentPage.Content>
</ContentPage>

Are there other additional packages I should be using to get this working?

NavBar BackButton error "Index was outside the bounds of the array"

$
0
0

I have a custom renderer that allows me to have "Cancel" & "Save" on the ioS NavBar

My custom renderer
'
[assembly: ExportRenderer(typeof(CustomModalPage), typeof(CustomContentPageRenderer))]
namespace MyProject.iOS
{
public class CustomContentPageRenderer : PageRenderer
{

    public new CustomModalPage Element
    {
        get { return (CustomModalPage)base.Element; }
    }

    public override void ViewWillAppear(bool animated)
    {
        base.ViewWillAppear(animated);

        var navigationItem = this.NavigationController.TopViewController.NavigationItem;

        var LeftNavList = new List<UIBarButtonItem>();
        var rightNavList = new List<UIBarButtonItem>();

        for (var i = 0; i < Element.ToolbarItems.Count; i++)
        {

            var reorder = (Element.ToolbarItems.Count - 1);
            var ItemPriority = Element.ToolbarItems[reorder - i].Priority;

            if (ItemPriority == 1)
            {
                UIBarButtonItem LeftNavItems = navigationItem.RightBarButtonItems[i];
                LeftNavList.Add(LeftNavItems);
            }
            else if (ItemPriority == 0)
            {
                UIBarButtonItem RightNavItems = navigationItem.RightBarButtonItems[i];
                rightNavList.Add(RightNavItems);
            }
        }

        navigationItem.SetLeftBarButtonItems(LeftNavList.ToArray(), false);
        navigationItem.SetRightBarButtonItems(rightNavList.ToArray(), false);

    }
}

}`

I wrap my new page in a new NavigationPage and then call Navigation.PushModalAsync(myModalPage)
This all works fine & I can Save & Cancel.

There is an additional "Help" page that I call from this Modal page using Navigation.PushAsync(userHelpPage)
When the navbar back button is pressed on the Help Page I get the error
"Index was outside the bounds of the array"

If I comment out the Custom renderer the error is not thrown. Can anyone shed some light on what might be going on?

how to highlight the button color when it click ?

$
0
0

Hi,
I have 5 buttons on my screen. by default button text color is blue color and I didn't set the border and background color for those controls.
Here I want to highlight the clicked button. How can we do this in Xamarin forms using Xaml and view models ?
is it possible to do this without using the codebehind file(.cs file).

Any help appreciated. Thank you.

Custom Renderer OnElementChanged e.OldElement always null?

$
0
0

Using: Xamarin Forms 2.3.3.175 & 2.3.3.180 we get a problem in Android when using a custom renderer:

In our Android implementation of the custom view renderer, the OnElementChanged event e.NewElement is always set and e.OldElement is always null. In a previous version of Forms/MonoDroid e.OldElement was populated when expected.

This issue is causing problems with the way we've developed some of our controls, has anyone else had the same experience?

Launching Phone dialer, Email composer, Sms composer

$
0
0

Hi,

I'm using XAML Xamarin.Forms and would like to trigger opening Phone, Email Composer, Sms in Android and iOS when somebody clicks a phone number, email address, or sms phone number. Similar to the HTML mailto:, tel: and sms: tags.

Does anyone know how to best do this?

Thanks!

Chris


How to make iOS device vibrate even when ringer is turned on

$
0
0

I am using the Vibrate plugin created by @JamesMontemagno . On iOS, I find that the vibration only happens if the ringer sound is turned off. Is there any way of getting vibration to work on iOS regardless of the ringer setting?

RuntimeException: Unable to instantiate application MainApplication

$
0
0

Hello i trying to create an app for ios and android in xamarin!

The app is running on ios! But when i try to start the app on android i got this error:

[AndroidRuntime] java.lang.RuntimeException: Unable to instantiate application md5de7e65cae3ac6a0c5094f6b31bd3f499.MainApplication: java.lang.ClassNotFoundException: Didn't find class "md5de7e65cae3ac6a0c5094f6b31bd3f499.MainApplication" on path: DexPathList[[zip file "/data/app/com.fb.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.fb.test-1/lib/x86, /data/app/com.fb.test-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]
[AndroidRuntime] at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
[AndroidRuntime] at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
[AndroidRuntime] at android.app.ActivityThread.-wrap1(ActivityThread.java)
[AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:102)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:148)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:5417)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "md5de7e65cae3ac6a0c5094f6b31bd3f499.MainApplication" on path: DexPathList[[zip file "/data/app/com.fb.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.fb.test-1/lib/x86, /data/app/com.fb.test-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]
[AndroidRuntime] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
[AndroidRuntime] at android.app.Instrumentation.newApplication(Instrumentation.java:981)
[AndroidRuntime] at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
[AndroidRuntime] ... 9 more
[AndroidRuntime] Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.fb.test-1/base.apk
[AndroidRuntime] at dalvik.system.DexFile.openDexFileNative(Native Method)
[AndroidRuntime] at dalvik.system.DexFile.openDexFile(DexFile.java:295)
[AndroidRuntime] at dalvik.system.DexFile.(DexFile.java:80)
[AndroidRuntime] at dalvik.system.DexFile.(DexFile.java:59)
[AndroidRuntime] at dalvik.system.DexPathList.loadDexFile(DexPathList.java:279)
[AndroidRuntime] at dalvik.system.DexPathList.makePathElements(DexPathList.java:248)
[AndroidRuntime] at dalvik.system.DexPathList.(DexPathList.java:120)
[AndroidRuntime] at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:48)
[AndroidRuntime] at dalvik.system.PathClassLoader.(PathClassLoader.java:65)
[AndroidRuntime] at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
[AndroidRuntime] at android.app.LoadedApk.getClassLoader(LoadedApk.java:376)
[AndroidRuntime] at android.app.LoadedApk.makeApplication(LoadedApk.java:568)
[AndroidRuntime] ... 9 more
[AndroidRuntime] Suppressed: java.lang.ClassNotFoundException: md5de7e65cae3ac6a0c5094f6b31bd3f499.MainApplication
[AndroidRuntime] at java.lang.Class.classForName(Native Method)
[AndroidRuntime] at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
[AndroidRuntime] at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
[AndroidRuntime] ... 12 more
[AndroidRuntime] Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

New Blog Posts

How to play a video in Xamarin Forms? Its possible?

$
0
0

Its possible to play video in xamarin forms?. (Not in separate native code)

I want to play video using portable project.. Its possible in official code or any other 3rd parties available?

Any one suggest me..

Xamarin Forms Master Detail page- Menu not appearing in UWP phone

$
0
0

I am trying to create a Master detail page using Xamarin forms. I am able to get it working fine on android and the windows 10 simulator but the menu is not visible in the windows phone emulator. I am using the UWP project and a windows 10 phone emulator. What could I be doing wrong ?

Viewing all 91519 articles
Browse latest View live


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