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

How to change toolbar colors?

$
0
0

Hi, first time asking a question here. I've spent hours losing my mind trying to add a toolbar to my app and style it to my liking. I finally got it to show up, but cannot figure out how to simply change the background and text colors. I've tried many different things found on these forums and on other websites but nothing has worked so far.

Here are my files:

MainPage.xaml
(taken from this project)

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyApp.MyPage">
    <ContentPage.ToolbarItems>
           <ToolbarItem Text="edit" Order="Primary">
                <ToolbarItem.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource"
                                iOS="edit.png"
                                Android="ic_action_edit.png"/>
                </ToolbarItem.Icon>
            </ToolbarItem>
            <ToolbarItem Text="search" Order="Primary">
                <ToolbarItem.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource"
                                iOS="search.png"
                                Android="ic_action_search.png"/>
                </ToolbarItem.Icon>
            </ToolbarItem>
            <ToolbarItem Text="refresh" Order="Primary">
                <ToolbarItem.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource"
                                iOS="reload.png"
                                Android="ic_action_refresh.png"/>
                </ToolbarItem.Icon>
            </ToolbarItem>
            <ToolbarItem Text="explore" Order="Secondary" />
            <ToolbarItem Text="discover" Order="Secondary" />
            <ToolbarItem Text="evolve" Order="Secondary" />
        </ContentPage.ToolbarItems>
</ContentPage>

MainPage.xaml.cs

using Xamarin.Forms;
namespace MyApp
{
    public partial class MyPage : ContentPage
    {
        public MyPage()
        {
            InitializeComponent();
        }
    }
}

App.xaml

<Application
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyApp.App">
    <Application.Resources>
        <ResourceDictionary>
            <Color x:Key="accentColor1">#F85A2F</Color>
            <Color x:Key="accentColor2">#C94A28</Color>
            <Color x:Key="primaryColor1">#222222</Color>
            <Color x:Key="primaryColor2">#2E2E2E</Color>
            <Color x:Key="backgroundColor1">#FFFFFF</Color>
            <Color x:Key="backgroundColor2">#F8F8F8</Color>
            <Color x:Key="textColor">#757575</Color>
            <Style TargetType="NavigationPage">
                <!-- Doesn't change anything! -->
                <Setter Property="BarBackgroundColor" Value="Color.Red"/>
                <Setter Property="BarTextColor" Value="#FFFFFF"/>
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

App.xaml.cs

using Xamarin.Forms;
namespace MyApp
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
            MainPage = new NavigationPage(new MyPage());
        }
    }
}

MainActivity.cs

using Android.App;
using Android.OS;
using Android.Content.PM;
namespace MyApp.Droid
{
    [Activity(Label = "My App", Theme = "@style/AppTheme", ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize)]
    public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            Xamarin.Forms.Forms.Init(this, bundle);
            App app = new App();
            LoadApplication(app);
        }
    }
}

styles.xml
(note that I do have a colors.xml but didn't think it was necessary to include it)

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
    </style>
</resources>

So with this code I'm able to see my toolbar with the correct layout and items, but there seems to be no way to change the background or text colors. However, I think the problem (at least with the background) might just be that the toolbar is transparent because setting "android:windowBackground" in styles.xml to something besides white not only changes the page background but also the background of the toolbar. As you can see I already tried setting "BarBackgroundColor" and "BarTextColor" in App.xaml, but it does nothing. I also tried putting its equivalent in App.xaml.cs, but that failed too.

Hoping someone has some information about this since I can't find anything helpful.


ListView Bindings Issue

$
0
0

Hello, I am having a little issue using List View in Xamarin Forms.

I have populated my ListView using the MVVM Architecture. The codes are as follows :smile:
What I want to achieve is to have my TextColor Attribute turn Red for one of my Label in the textview.. How can I achieve this correctly ?
**My XAML Page : **

 <ListView.ItemTemplate>
   <DataTemplate>
     <ViewCell>
       <Grid Padding="12">
          <Label Text="{Binding UID}" TextColor="Black" FontSize="12"/>
          <Label Text="{Binding battery}" TextColor="{Binding StatusColor}" FontSize="12" XAlign="End"/>
       </Grid>
     </ViewCell>
   </DataTemplate>
 </ListView.ItemTemplate>

</ListView>

**My TagsViewModel.cs (MVVM) : **

public class TagsViewModel : INotifyPropertyChanged
{
private List _tagsModel;

    public List<Tags> TagsModel
    {
        get { return _tagsModel; }
        set
        {
            _tagsModel = value;
            OnPropertyChanged();
        }
    }

    private string _statusColor;

    public string StatusColor
    {
        get { return _statusColor; }
        set
        {
            _statusColor = value;
            OnPropertyChanged();
        }
    }

    public TagsViewModel()
    {
        TagsModel = new List<Tags>();

        TagsModel.Add(new Tags() { id = 1, UID = "324324", UIDid = 4324325, battery = "14/02/2017" });
        TagsModel.Add(new Tags() { id = 2, UID = "258225", UIDid = 4324325, battery = "15/02/2017" });
        TagsModel.Add(new Tags() { id = 3, UID = "854224", UIDid = 4324325, battery = "16/02/2017" });
        TagsModel.Add(new Tags() { id = 4, UID = "582253", UIDid = 4324325, battery = "14/02/2017" });
        TagsModel.Add(new Tags() { id = 5, UID = "253245", UIDid = 4324325, battery = "17/02/2017" });

        StatusColor = "Red";



    }

    public event PropertyChangedEventHandler PropertyChanged;

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

Xamarin.Forms (Android) Entry with full border

$
0
0

Is there any custom renderer solution, for customizing Entry for full 4 side border?

Bluetooth for Android and UWP

$
0
0

Hi,

I'm about to start a new project, where I want to connect a NFC Tag reader via bluetooth to a Android and Windows Tablet.
First of all I want to check how to implement a bluetooth example. I was looking for a up-to-date tutorial but I could not find something helpfull.

I found this Xamarin.Forms NuGet but it is not supporting UWP at the moment: https://github.com/aritchie/bluetoothle
Also found this on the Xamarin page: https://developer.xamarin.com/samples/mobile/BluetoothLEExplorer/ but the code is deprecated wich links me to the monkey.robotics page, but I don't want to use that hole "framework" just want to get the bluetooth running as easy as possible on Android and UWP.

Any other links/tutorials?

Touch Coordinates in TapGestureRecognizer?

$
0
0
  1. How do I get the Touch position (basically, the X,Y co-ordinates) when a user does a TapGesture on a view (say an image).
  2. Is there any equivalent of TouchesBegan,Ended from iOS in Xamarin.Forms - or if we need such granular control then we should implement it in Native UI.
    (Sorry, if this was answered earlier - searching limited by Xamarin.Forms seems difficult in these forms - any hints on just searching a sub-forum)

How to select multiple images from gallery from both android and iOS device?

$
0
0

Hello,
I am working on xamarin.forms app. I am creating the app for android and iOS. I need to open the gallery and select multiple images from gallery of devices. How I can do this in xamarin.forms that can work for both android and iOS?

Regards,
Anand Dubey

How to authenticate web api service from xamarin forms app using Access Token?

$
0
0

The web api is registered in azure active directory. when i call that web request with access token, its giving Error: TrustFailure (The authentication or decryption has failed.)

How to navigate to a separate page from a TabbedPage's child's button?

$
0
0

Greetings.

So I am trying to make it so that on one of the children of a TabbedPage will through the click of a button open (or "push" as the documentation use) a separate page that will then with a button return to the TabbedPage's default page. I've tried PushModalAsync and PushAsync but nothing works. Whenever I click the button in the compiled app on the Android phone I am using to test I just get "Unfortunately (the application name) has stopped working" and the app quits and crashes when I click the button. I have no errors in the compiler and have been following the example projects and this is all done in C# with no XAML/AXML/AXML/LAXM/XMLA/LAXM involved.

I have looked over all the documentation and I cannot see what I am doing wrong. This is very frustrating and I would like a very clear example on how to do this if it is possible. Otherwise I can make the button display a pop-up, but it will still have to be able to navigate back to the default page of the TabbedPage's children.

Thank you very much in advance for helping out.


failed to change the title of detail page in MasterDetailPage on Xamarin Forms UWP

$
0
0

I got a weird problem. I created a master dateil page as the same with Xamarin sample code. like below code:

public class MainPage:MasterDetailPage
    {
        public MainPage()
        {
            this.Master=new ContentPage
            {
                Title="Menu Page",
                Content = new StackLayout{...}
            };

           this.Detail=new NavigationPage(new DetailPage());
        }
    }

In the constructor of detail page, I assign value to title properties, and it displays good. afterwards the title can't change in other ways. I tried to change the title of detail page in a button click event ,but failed.

Then I debuged the code and I found that the program assign value to title property successfully, but the UI cant display. I tested it on Xamarin Forms iOS and Xamarin Forms Android, they are good. It is weird, I have no idea about it. The detail Page code like below:

public class DetailPage:ContentPage
    {
        public DetailPage()
        {
            this.Title="Detail Page";
            .....

            btn.Clicked+=(s,e)=>
            {
                this.Title="Change page title";//assinment succeeded, but can't display
            };
        }

    }

Hunting Memory Leaks, best practices?

$
0
0

Hi,

I started a new Thread because this Title makes more sense.

What are your best strategies to hunt down MemoryLeaks, especialls on Android? How can I check if a certain object get's relased? Does it make sense to include a Debug.WriteLine into the Destructor of the Class of interest?

Does it make sense to call GC.Collect to see if memory stays constant?

Thanks for all help!

Best
Thomas

How to access controls defined in a ListView DataTemplate?

$
0
0

Hi,
Lets say I have a ListView in 'MyView' as follows:

<ListView x:Name="myList" ItemSource="{Binding MyData}">
  <ListView.ItemTemplate>
    <DataTemplate>
      <ViewCell>
        <StackLayout>
          <Label Text="{Binding FieldLabel}"/>
          <Entry x:Name="myEntry" Text="{Binding MyEntry}">
            <b:Interaction.Behaviors>
              <b:BehaviorCollection>
                <b:EventToCommand EventName="Completed" CommandParameter="{Binding .}" Command="{Binding Path=BindingContext.EntryCompletedCommand, Source={x:Reference Name=MyView}}"/>
              </b:BehaviorCollection>
            </b:Interaction.Behaviors>
          </Entry>
        </StackLayout>
      </ViewCell>
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>

MyData has x items in it, lets say 10.

How can I set focus to the next entry field to the next item from within the EntryCompletedCommand event? and when the last one is 'completed' then focusing the first entry in the listview?

I've searched for a while now and have not found a straight forward answer!

Forms9Patch: Simplify multi-device image management in your PCL Xamarin.Forms mobile apps

$
0
0

Announcement of Form9Patch

Xamarin Forms is great for developing apps on Android and iOS but it is missing two important tools for developers: scalable images and PCL multi-screen image management. Android developers use NinePatch bitmaps and the drawable directory naming convention for this purpose. Likewise, iOS developers use ResizeableImageWithCapInsets and the @2x, @3x, @4x file naming convention for this purpose.

Forms 9 Patch enhances Xamarin Forms to enable multi-resolution / multi-screen image management to PCL apps for iOS and Android.

What is it?

Simply stated, Forms9Patch is two separate elements (Image and ImageSource) which are multi-screen / multi-resolution extensions of their Xamarin Forms counterparts.

Forms9Patch.ImageSource

Xamarin Forms provides native iOS and Android multi-screen image management (described here). This requires storing your iOS images using the native iOS schema and storing your Android images using the Android schema. In other words, duplicative efforts to get the same results on both Android and iOS. Forms9Patch.ImageSource extends Xamarin.Forms.ImageSource capabilities to bring multi-screen image management to your PCL assemblies - so you only have to generate and configure your app's image resources once. Forms9Patch.ImageSource is a cross-platform implementation to sourcing multi-screen images in Xamarin Forms PCL apps as embedded resources.

Forms9Patch.Image

Forms9Patch.Image compliments Xamarin.Forms.Image to provide Xamarin Forms with a scaleable image element. Scalable images are images that fill their parent view by stretching in designated regions. The source image for the Forms9Patch.Image element can be specified either as a Forms9Patch.ImageSource or a Xamarin.Forms.ImageSource. Supported file formats are NinePatch (.9.png), .png, .jpg, .jpeg, .gif, .bmp, and .bmpf.

Example code

After adding the file bubble.9.png to your PCL project assembly as an EmbeddedResource, you can display it using something like the following:

var bubbleImage = new Forms9Patch.Image () {
    Source = ImageSource.FromResource("MyDemoApp.Resources.bubble.9.png"),
    HeightRequest = 110,
}
var label = new label () {
    Text = "Forms9Path NinePatch Image",
    HorizontalOptions = LayoutOptions.Center,
}

Example XAML

In Xamarin Forms, access to embedded resources from XAML requires some additional work. Unfortunately, Forms9Patch is no different. As with Xamarin Forms, you will need (in the same assembly as your embedded resource images) a simple custom XAML markup extension to load images using their ResourceID.

    [ContentProperty ("Source")]
    public class ImageMultiResourceExtension : IMarkupExtension
    {
        public string Source { get; set; }

        public object ProvideValue (IServiceProvider serviceProvider)
        {
            if (Source == null)
                return null;

            // Do your translation lookup here, using whatever method you require
            var imageSource = Forms9Patch.ImageSource.FromMultiResource(Source);

            return imageSource;
        }
    }

Once you have the above, you can load your embedded resource images as shown in the below example. Be sure to add a namespace for the assembly that contains both your MarkupExtension and your EmbeddedResources (local in the below example).

<?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:MyXamlDemo;assembly=MyXamlDemo"
    x:Class="MyXamlDemo.MyPage"
    Padding="5, 20, 5, 5">
    <ScrollView>
        <ScrollView.Content>
            <StackLayout>
            <Label Text="Xamarin.Image"/>
            <Image Source="{local:ImageMultiResource Forms9PatchDemo.Resources.image}"/>
            </StackLayout>
        </ScrollView.Content>
    </ScrollView>
</ContentPage>

Where to learn more

Project page: http://Forms9Patch.com
Nuget page: https://www.nuget.org/packages/Forms9Patch/0.9.1
Demo app repository: https://github.com/baskren/Forms9PatchDemo

Changing Android's StatusBar color (statusBarColor/colorPrimaryDark)

$
0
0

I'm having quite the struggle with changing the StatusBar's color for the Android version of my Xamarin.Forms application.
After searching the topic for quite a while I couldn't find any property to set it, so I tried it with Styles:

<item name="android:colorPrimaryDark">@color/actionBarTextWhite</item>
<item name="android:statusBarColor">@color/actionBarTextWhite</item>
<item name="android:colorPrimary">@color/actionBarGreen</item>

It accepts and also applies the colorPrimary for the ActionBar, so my style is active and correctly implemented. However, the StatusBar remains black.
I tried it with statusBarColor first, then with colorPrimaryDark, then with both, since they're both colors for the StatusBar as mentioned here:
http://developer.xamarin.com/guides/android/platform_features/android_l/material_theme/

Is this a bug, am I missing something or is it simply a not-implemented feature?

Regards

No focus issue : Entry inside a listviewDatatemplate

$
0
0

Hello,

In my application, I have a listview with itemTemplate that is choosen by a templateselector.

This is my listView with the itemTemplate :

<ListView x:Name="ContentList" Grid.Row="2" Grid.Column="0"
                      Grid.ColumnSpan="11" Grid.RowSpan="3"
                      ItemsSource="{Binding Content}" HasUnevenRows="True">
              <ListView.ItemTemplate>
                <DataTemplate>
                  <ViewCell>
                    <Grid x:Name="Grid" BindingContext="{Binding}" BackgroundColor="White">
                  <Grid.RowDefinitions>
                    <RowDefinition Height="60" />
                  </Grid.RowDefinitions>
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="Auto" />
                  </Grid.ColumnDefinitions>
                    <!--<Entry Grid.Row="0" Grid.Column="2" BindingContext="{Binding}" Text="{Binding Value}"
                                                                WidthRequest="250"
                                                                IsEnabled="True"
                                                                VerticalOptions="Center"
                                                                Placeholder="{Binding Name}" />-->
                    <controls:ExtendedEntry Grid.Row="0" Grid.Column="2" BindingContext="{Binding}" Text="{Binding Value}"
                                            WidthRequest="250"
                                            IsEnabled="True" IsPassword="{Binding IsPassword}"
                                            VerticalOptions="Center"
                                            Placeholder="{Binding Name}" />
                      </Grid>
                  </ViewCell>
                </DataTemplate>
              </ListView.ItemTemplate>
            </ListView>

This is a small viewModel to test with :

public class Block
{
    public Block(string name, object value, bool isPassword)
    {
    Name = name;
    Value = value;
    IsPassword = isPassword;
    }

    public object Value {get;set;}
    public string Name {get;set;}
    public IsPassword {get;set;}
}

public class MainVM
{
    public ObservableCollection<Block> Content {get;set;}
    public MainVM()
    {
    Content = new ObservableCollection<Block>();
    var block1 = new Block("User", "MyUsername", false);
    Content.Add(block1);
    var block2 = new Block("Password", "MySecretPassword", true);
    Content.Add(block2);
}

My customControl is here : http://pastebin.com/Kq7kMJTE

My renderer : http://pastebin.com/jqxR4XXu
Remove the regex match, because it's a custom property of the control that I removed, it's not mandatory

I can't get the focus to my entry, I manage to force the keyboard to appear, but my text is never update if I press a key.

Thanks for your help

GREF ListView and PopToRootAsync (Xamarin Forms 2.3.3.180 targeting Android)

$
0
0

Hi,

I am asking for your help as I am new to Xamarin but not to .NET. I am working on a wizard like project based on a lot ListView(s) which are leaking GREF. (JNI Global REFerences)
As some of you probably know, the GREF limit of the Xamarin emulator is 2000 references. If there is a leak this could become a problem really quickly.

To investigate this, I have enabled GREF tracking on my emulator and created a new shared Forms solution to keep things simple. The solution contains only one form with a ListView and several buttons for tests. The first button reloads another instance of the (same) page with a populated ListView (3 items). If I click on it, I can see the GREF increase in the output windows in Visual Studio. Then I also have one button to call the garbage collector and the others are button to pop pages in different ways.

This is becoming ugly now, when I load several instance (of the page) and the call PopToRootAsync without animation (a Xamarin Method), the GREF never decrease. If I use the garbage collector multiple times (button Clean IT), it doesn't decrease. It I go drink a coffee and comeback and call the GC, it doesn't decrease.

This is really a problem and probably a bug. I have done some reseach to find a workaround and tried a lot of (sometime random) things and compared GREF metrics to find this:

  • If the PopAsync is animated, more GREF are released. (why?)
  • If I clear the ObservableCollection before the PopAsync more GREF are released. (proly because items in ListView are released?)
  • If I PopAsync the page from the view itself, a lot more GREF are released. (this one sound like a X-File episode...)

So I created a recursive method in the view to do the same as a PopToRootAsync but on the view:

//Homemade PopToRoot each view pop itself recursively
//must be on the view to work! (I don't know why...)
public async Task PopToRoot(bool animate)
{
    var nav = Application.Current.MainPage.Navigation;
    if (nav.NavigationStack.Count > 1) //Don't touch the root
        if (nav.NavigationStack[nav.NavigationStack.Count - 1].BindingContext is IDisposable) // Clean Collections if ViewModel Is Disposable
            (nav.NavigationStack[nav.NavigationStack.Count - 1].BindingContext as IDisposable).Dispose();

    await nav.PopAsync(animate);

    if (nav.NavigationStack.Count > 1 && nav.NavigationStack[nav.NavigationStack.Count-1] is ListViewPage)
        await (nav.NavigationStack[nav.NavigationStack.Count - 1] as ListViewPage).PopToRoot(animate); //Recursive Pop
}

Using this method released the most GREF. I have run some tests with other methods in my solution:

  • Xamarin PopToRootAsync not animated
  • Xamarin PopToRootAsync animated
  • Recursive PopToRootAsync not animated
  • Recursive PopToRootAsync animated

I have defined a test protocol, but without the call to Dispose (to be able to compare with the Xamarin PopToRootAsync method)

0) Load the App and click on CleanIT several times -> GC.Collect()
1) Write down the current GREF
2) Load the page 3 times
3) Write down the current GREF
4) Use the tested method to PopToRootAsync
5) Click on (CleanIT) -> GC.Collect()
6) Write down the current GREF
7) Click on CleanIT multiple time (until GREF is stabilized)
8) Write down the current GREF
9) Calculate the delta between 8 and 1 (this should be the number of GREF leaked)
10) GOTO 1

The results are:

  • Recursive PopToRootAsync animated: 42 GREFs not released
  • Recursive PopToRootAsync not animated: 156 GREFs not released
  • Xamarin PopToRootAsync animated: 125 GREFs not released
  • Xamarin PopToRootAsync not animated: 185 GREFs not released

If I clean the collection before the Recursive PopToRootAsync animated: 14 GREFs are not released (this is really better than 185 leaked GREFs...)

I have attached the zip file of the solution with this post. Since I am new, I would like to know what you think about it, if you have a better solution to collect all the GREFs and if this should be reported as a bug.

Thanks!


Prism 6.2 + AdMob

$
0
0

Hi everyone,

I watched brianlagunas video on his new Prism and was blown away by the simplicity. I have created serval projects using this framework. I have to say that it's getting hard to back when you have tried this framework. It's all working very good for my needs and all. I work with Unity all the time and gave Prism a go a few years back. But the video made me try this again on in the mobile world. Works like a charm. I still have some issues with async methods that returns void rather than Task - I'm sure that is minors. This is not what this question is about. The question is about:

I'd like to have ads in my apps. And there are no "good" and easy way to do this. I'm sure once I have found a way I would find the question very silly. But for now this not going to well. I'd like to use "AdMob". Any other will also do. But AdMob is good on iOS and Android.

I'm following the guide from AdMob. They are telling me to do a "App.Configure();" in the iOS AppDelegate. That's good and all. Problem is that my "App.cs" is not extending the old class but the "PrismApplication". I'm sure this is the problem. The PrismApplication does not have this. Maybe that the old extended class had this "Configure()".

Am I missing something here?

Most reagards
Bo

Auto size custom ViewCell based on its contents, inside a TableView

$
0
0

Hi,
Ive seen similar ListView based questions but noting TableView related. I have the following:

TableView
UnevenRows = true
TableSection
TableSection etc
TableSection
MyViewCell
Grid with 3 columns, middle column is a word wrapping label

No matter what I do I cannot get the MyViewCell to autosize to its contents. I can explicitly set the height of the cell but I won't know it ahead of time. The grid and label in the MYViewCell has VerticalOptions = LayoutOptions.FillAndExpand, in fact Ive tried adding that to everything that takes it in the entire stack.

Is this situation not supported? Crazy if not.

Cheers
John

Installing SQLite-net-pcl

$
0
0

I am trying to convert my project from SQLite.Net-PCL to sqlite-net-pcl (latest stable version; 1.3.1), as it says on Xamarin's working with databases, but when I install it, it has to install 40 packages (or so) as listed below

Microsoft.NETCore.Platforms 1.0.1
Microsoft.NETCore.Targets 1.0.1
runtime.native.System   4.0.0
SQLitePCLRaw.core 1.1.2
SQLitePCLRaw.bundle_green 1.1.2
System.Collections 4.0.11
System.Collections.Concurrent 4.0.12
System.Diagnostics.Debug 4.0.11
System.Diagnostics.Tools 4.0.1
System.Diagnostics.Tracing 4.1.0
System.Globalization 4.0.11
System.IO 4.1.0
System.IO.Compression 4.1.0
System.Linq 4.1.0
System.Linq.Expressions 4.1.0
System.Net.Http 4.1.0
System.Net.Primitives 4.0.11
System.ObjectModel 4.0.12
System.Reflection 4.1.0
System.Reflection.Extensions 4.0.1
System.Reflection.Primitives 4.0.1
System.Resources.ResourceManager 4.0.1
System.Runtime 4.1.0
System.Runtime.Extensions 4.1.0
System.Runtime.InteropServices 4.1.0
System.Runtime.Numerics 4.0.1
System.Text.Encoding 4.0.11
System.Text.Encoding.Extensions 4.0.11
System.Text.RegularExpressions 4.1.0
System.Threading 4.0.11
System.Runtime.InteropServices.RuntimeInformation 4.0.0
System.Threading.Tasks 4.0.11
System.Xml.ReaderWriter 4.0.11
System.Xml.XDocument 4.0.11
NETStandard.Library 1.6.0
sqlite-net-pcl 1.3.1

I understand that it needs some packages, but it seems like a lot of packages to me.
I am using Xamarin.Forms version 2.3.3.180 (the latest stable)

And if I continue the installation, an error like this occurs

Could not install package 'System.Runtime.InteropServices.RuntimeInformation 4.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

How can I install sqlite-net-pcl, so I can continue working with SQLite on Android N?

How to prevent scrollview from scrolling over other layouts in the page?

$
0
0

Hello, I have an issue with the scrollview when it scrolls over other layouts in the same page. I set width and height request and the property IsClippedToBounds = true, but the issue still happens. Here is my layout for the page:

ContentPage
MainLayout
GridTop
Scrollview
GridBottom

Inside the scrollview is a list of radio buttons. I don't know if it would affect the scrollview. Could you please help me to solve this problem? Thanks in advance.

Strange behaviour with Color function

$
0
0

Hi guys,
I have a strange problem with a function that returns Color (Xamarin.Forms). My idea is to show a box with different background depends on the AppointmentStatus. I created an extension for an enum like this

public static Color ColorForStatus(this AppointmentStatus status)
{
    Color rtn = Color.Transparent;

    switch (status)
    {
        case AppointmentStatus.Active:
            rtn = Color.FromHex("#654BE");
            break;
        case AppointmentStatus.Cancelled:
            rtn = Color.FromHex("#E14063");
            break;
        case AppointmentStatus.Completed:
            rtn = Color.FromHex("#C4E7EE");
            break;
        case AppointmentStatus.Hold:
            rtn = Color.FromHex("#84CEDD");
            break;
        case AppointmentStatus.InProgress:
            rtn = Color.FromHex("#B1D1DE");
            break;
        case AppointmentStatus.Paused:
            rtn = Color.FromHex("#F1E19E");
            break;
        default:
            rtn = Color.Transparent;
            break;
    }

    return rtn;
}

If I call this function rtn has the color I expected but on the screen I can't see any color. To try to fix it, then I created a function with similar code

public static class ColourHelpers
{
    /// <summary>
    /// Determine the color for an appointment status
    /// </summary>
    /// <param name="status">The status.</param>
    /// <returns>Color.</returns>
    public static Color ColorForStatus(this AppointmentStatus status)
    {
        Color rtn = Color.Transparent;

        switch (status)
        {
            case AppointmentStatus.Active:
                rtn = Color.FromHex("#654BE");
                break;
            case AppointmentStatus.Cancelled:
                rtn = Color.FromHex("#E14063");
                break;
            case AppointmentStatus.Completed:
                rtn = Color.FromHex("#C4E7EE");
                break;
            case AppointmentStatus.Hold:
                rtn = Color.FromHex("#84CEDD");
                break;
            case AppointmentStatus.InProgress:
                rtn = Color.FromHex("#B1D1DE");
                break;
            case AppointmentStatus.Paused:
                rtn = Color.FromHex("#F1E19E");
                break;
            default:
                rtn = Color.Transparent;
                break;
        }

        return rtn;
    }
}

And also in this case the result is the same. If I check the value in Visual Studio, the value seems correct but the function is unknown identifier. See the image.

What?

If in the main I'm using the same switch, I can see the colour in the screen as you can see in the picture below.

Screen

Thank you in advance.

Viewing all 91519 articles
Browse latest View live


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