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

akavache not caching in ios simulator/device

$
0
0

using xamarin forms v.3.1 and akavache v5 + akavache.sqlite3 v5.

in app.xaml.cs I initialized akavache

       BlobCache.ApplicationName = "EF_Cache";
       BlobCache.EnsureInitialized();

And to cache data i use localmachine

`   await BlobCache.LocalMachine.InsertObject<List<int>>("FavouriteTeams", FavouriteTeam, TimeSpan.FromDays(300));`

To retrieve data i do

 `  var FavouritesList = await BlobCache.LocalMachine.GetObject<List<int>>("FavouriteTeams");`

The following code works fine in android devices with no issue but when i tried it on ios device/simulator it fails with no errors, the getobject<> just return null when restarting the app.

is there any thing is missing or an extra thing should be configured in ios apps in properties or info.plist.


Xamarin.Forms creates two instances of renderer for one control instance.

$
0
0

I've create a simple view in XF project just to make a renderer for this to use native Android features.

public class CollectionView : View
{
    public CollectionView()
    {
        Margin = new Thickness(0, 10, 0, 0);
    }
}

I am using this view only once for all project in one xaml file. Next I've created a custom renderer for this view in my Android project.

[assembly: ExportRenderer(typeof(CollectionView), typeof(CollectionViewRenderer))]
namespace Project.Forms.Droid.Renderers
{
    public class CollectionViewRenderer : ViewRenderer<CollectionView, Android.Views.View>
    {
    ...
    }
}

For some reason ctor of CollectionViewRenderer calls two times. I have some event subscriptions inside and when event triggers code from CollectionViewRenderer runs two times in two different instances. Does anybody know why this may happens and how to fix this?

iOS Pull to refresh

$
0
0

I want to implement pull to refresh on a Forms project I have, but after the refresh is over, the Cells in the ListView are empty on iOS. this is what I got

<ListView x:Name="listView" Grid.Row="2" Grid.Column="0" ItemsSource="ActivityList" BackgroundColor="#D6D6D6" IsVisible="False"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <custom:CustomFrame Padding="0,5,0,0" Margin="0,10,0,0" > <StackLayout> <Label Style="{StaticResource bold}" FontSize="Large" TextColor="#c4950b" Margin="10,0,0,0" x:Name="labelName" Text="{Binding Key}" /> <local1:Carousel ActList="{Binding Value}" KeyName="{Binding Key}" /> </StackLayout> </custom:CustomFrame> </ViewCell.View> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>
ListView CustomRenderer
`
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizPass.iOS;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(ListView), typeof(NoBarListView))]
namespace BizPass.iOS
{
class NoBarListView : ListViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (Control != null)
{
var itemCount = Control.NumberOfRowsInSection(0);
System.Diagnostics.Debug.WriteLine(itemCount);
Control.ShowsHorizontalScrollIndicator = false;
Control.ShowsVerticalScrollIndicator = false;

        }
    }
}

}
`

Frame CustomRenderer
`
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizPass.iOS;
using CoreGraphics;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(BizPass.Controls.CustomFrame), typeof(CustomFrame))]
namespace BizPass.iOS
{
class CustomFrame : FrameRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);

        if(e.OldElement != null)
        {
            var rect = e.OldElement.Bounds.ToRectangleF();
            this.Draw(rect);
        }

        //Forces the element to be redrawn when coming into veiw. Specifically for upcoming list
        ContentMode = UIViewContentMode.Redraw;
    }

    //Method to draw the control
    public override void Draw(CGRect rect)
    {
        // Update shadow to match better material design standards of elevation
        Layer.ShadowRadius = 2.0f;
        Layer.ShadowColor = UIColor.LightGray.CGColor;
        Layer.ShadowOffset = new CGSize(2, 2);
        Layer.ShadowOpacity = 0.80f;
        Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath;
        Layer.MasksToBounds = false;
        base.Draw(rect);
    }
}

}

`

Unable to compile with RestSharp package

$
0
0

Hi everyone,

On a new project I have a build error when I try to add RestSharp on my iOS project. It's a Xamarin.Forms solutions using .NET Standard 2.0. I made a project using RestSharp and I need to add this nuget to my iOS project.

When I try to compile I have this error:

/Users/.../MyProject.iOS/CSC: Error CS1703: Multiple assemblies with equivalent identity have been imported: '/Users/.../.nuget/packages/system.reflection.emit/4.3.0/ref/netstandard1.1/System.Reflection.Emit.dll' and '/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades/System.Reflection.Emit.dll'. Remove one of the duplicate references. (CS1703)

And many errors because of missing this reference.
My iOS csproj looks like:

<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> ... Many build configuration ... <ItemGroup> <Compile Include="Main.cs" /> <Compile Include="AppDelegate.cs" /> <None Include="Entitlements.plist" /> <None Include="Info.plist" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Xamarin.iOS" /> </ItemGroup> <ItemGroup> <PackageReference Include="Xamarin.Forms"> <Version>3.1.0.697729</Version> </PackageReference> <PackageReference Include="RestSharp"> <ExcludeAssets>all</ExcludeAssets> <Version>106.3.1</Version> </PackageReference> </ItemGroup> <ItemGroup> <ProjectReference Include="... Reference to my Forms project ..."> <Project>{19803808-B8EA-49D9-845B-ECF7CAFAC5D8}</Project> <Name>Live</Name> </ProjectReference> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> </Project>

Does anyone has an idea ?

Florian.

How to add Video in iOS splash screen ?

$
0
0

How to add Video in ios splash screen ? using xamarin forms

please advise or hint

How to reduce the size of ActivityIndicator in xamarin forms

$
0
0

Hi, I am using ActivityIndicator, as loading Indicator, i need to reduce the size of the same.. how we can.... anybody please... thanks... <ActivityIndicator x:Name="activity" Color="Blue" BackgroundColor="Transparent"/>

Is there a performance benefit or other reasons to convert a project from PCL to .netstandard2.0?

$
0
0

So I have an app live on the App Store and Google Play.

The project consists of:

  • An Android project and iOS project
  • Several PCL projects (Presentaion, Business, Data, BDO, Framework)
  • And several .NetFramework 4.6 web-service projects that reference the BDO and Framework PCLs.

Is there a significant benefit in converting this solution into .netstandard2.0 projects and an shproj?
There are quite a few nuget packages in both the mobile projects and the web-service projects, and I believe I'll have to upgrade to .NetFramework 4.6.1 or higher. I'm concerned about introducing incompatibilities or run-time issues.

Thanks

Page Navigation - Recommended Method

$
0
0

I'm working on my first Xamarin Forms application (iOS and Android) and so far whenever I've had to change pages, I just do so from the code behind file. While my application works thus far, I feel like this is wrong as the application gets bigger and there are API calls between pages, commands, etc. Specifically because I'm having a problem where I have a button that calls a command (which calls a REST API in the ViewModel) and has an event handler to change the page in the code behind.

I know you can pass the Navigation stack to the ViewModel but is this the recommended method? Does it matter at all? I'm really curious what the "official" way to do this is and how problems like the one I'm facing should be handled.

Thanks in advance!


How to identify components that need removing when upgrade to VS 15.6?

$
0
0

Having (foolishly, based on experience so far) upgraded to Visual Studio 15.6, I'm getting the message about Xamarin Components:

I've been through the csproj files and removed any that are clearly Components. Followed the instructions on the linked documentation page. Still getting the message though. Is there anywhere that Visual Studio 15.6 logs or outputs what it considers to be the problem components? The message being displayed is an example of really bad UI - tell the user there's a problem, but not identify the problem properly. That's right up there with engine management lights on cars (surely a device primarily intended to raise money for car mechanics/franchises).

I have a solution with multiple projects, many of which make use of third-party plugins etc. Stripping everything down and adding bits back to find the cause is going to make the whole upgrade of Visual Studio leave an even worse taste than it already has, so I'm hoping there's a detailed log somewhere that tells me what VS thinks is the problem.

cc @DavidOrtinau

When creating Custom Renderer how to call native method from PCL?

$
0
0

Easy for you gurus...

I'm creating a custom renderer for Maps.
Now I'd like to create an additional custom method (e.g. updateMarkers) on the PCL class that extends Maps.
How do I implement that method on the native layer? Do I need to create a Dependency Service?

Bear with me, I'm doing this for the first time... :)

Thanks!

Navigation Page don't work ?

$
0
0

I want when I click to image to navigate to other page , I have a code like this
'
<Image.GestureRecognizers>


</Image.GestureRecognizers>
'

c#
'private void TapGestureRecognizer_Tapped_7(object sender, EventArgs e)
{
Navigation.PushAsync(new AddFriendPage());
}'

It's not working why ??

Why won't my Command trigger when my button is clicked?

$
0
0

Following MVVM principles, I am attempting to fire a command in my view-model when a button in the view is clicked.

I have a valid view and a valid view-model and the view-model is set as the DataContext for the view. To verify that I have a working binding to the view-model, I have created a Label, which I can successfully bind to a string property on the view-model. When I add the binding for the Button.Command, I get a completely useless error that says: 'Error while resolving expression: One or more errors occurred.'

Interestingly, I get this error if I define the type of the command as an ICommand. If I define it as Command, I don't get the error (but it still doesn't work).

One thing I wondered about is that I have defined my own ICommand interface to avoid pulling System.Windows.Input into my core logic module. And I have created my own concrete classes Command and Command<T> that implement the interface. Does this matter? It certainly didn't use to. I know this because I am currently recreating the whole project from another Xamarin.Forms application in which all of this commanding stuff was working just fine.

Anyone got any ideas? It would be nice even to get some communication from the binding engine. I love the idea of data binding but it seems to either work or not work and never seems to give useful information when it is not working.

  • Patrick

How to recover lost keystore

$
0
0

Hi Guys,

i have published some apps in Google Play store. Recently i have upgraded my OS and VS. Now when i go to project i am not able to see my keystore files. Please help me to resolve this issue. How to get those keystore files or i can create new keystore file and can i publish that apk as new version? I don't want publish new app.

Best Practice for Sensitive Configuration Data

$
0
0

What are some best practices around obtaining sensitive app configuration data? The two "data topics" I am mostly concerned about are client id and client secret for OIDC authentication, but this would also go for less sensitive data such as service endpoints, etc.

On first run of app, should a call be made to an (un)protected service endpoint to get this data?

iOS ScrollView jumps to top on layout change

$
0
0

On a XAML page I've got a ScrollViewer with many elements, so I can scroll vertically. I also have one or more elements right before the ScrollViewer, which turn visible or invisible based on certain criteria. Whenever the visibility changes the ScrollViewer jumps back to the top, but only on iOS. On UWP it remains its scroll position. Is this intended? Is there a common workaround to have the ScrollViewer remain its scroll position? Since there are more elements before the ScrollViewer I wouldn't like to register to all of them, but that's my last resort right now.


OnAppearing Event - Called before page is drawn on Android

$
0
0

I have a forms app and I am getting different behavior when I load my tabbed pages into the navigation stack. For some reason the OnAppearing method of one of my content pages gets fired immediately in Android only. Ios it functions as expected and only fires once the page "Appears". My question is how do I ensure my "OnAppearing" method actually fires when the page is drawn or Appears on the screen. I have some logic that refreshes the page and the fact it does not fire when it is initially navigated to is causing problems in Android. Here is my main page xaml when I setup my pages

      public MainPage()
            {
                InitializeComponent();

                Page HomePage, TestPage, UserPage = null;


                HomePage = new NavigationPage(new HomePage())
                {
                    Title = "Home" 
                };
               TestPage = new NavigationPage(new TestPage())
                {
                    Title = "Test"
                };
                UserPage = new NavigationPage(new UserPage())
                {
                    Title = "Users"
                };


            Children.Add(HomePage);
                Children.Add(TestPage);
                Children.Add(UsersPage);



    }

App.xaml.cs

    public App()
            {
                InitializeComponent();

                MainPage = new MainPage();

            }

    }

CAS Authentication

$
0
0

Hi,

We are currently developing a Xamarin, and we have to handle the authentication throught a CAS server. I don't have a clue how to achieve it...

Does someone already had to use CAS authentication on a Xamarin app, and if so, how can I do that ?

Thanks a lot !

I can not call a public method of another class from a Click Button on my MainPage

$
0
0

public partial class MainPage : TabbedPage
//the boton
public void MapaPuntaHelena_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new MapaPage());
BurroLocation();
}

//the other page xml with code behind
public partial class MapaPage : ContentPage

public void BurroLocation ()

    {
            MyMap.MoveToRegion(
            MapSpan.FromCenterAndRadius(new Position(28.687525, -13.83353), Distance.FromKilometers(5)));  
    }

How to add Fluent Design for MasterDetailPage of UWP in Xamarin.Forms?

iOS page covers status bar

$
0
0

What should I do to prevent the application cover the status bar area?
It covers the whole window and status icons are visible through top_grid on iPad 2 simulator


<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                       x:Class="test_cs_mobile_xamarin.main_page">
   <StackLayout>
      <Frame x:Name="top_frame" HasShadow="true" OutlineColor="Green" Padding="5,5,5,5" VerticalOptions = "FillAndExpand">
         <ScrollView  x:Name="top_scroll_view" VerticalOptions = "FillAndExpand">
            <Grid x:Name="top_grid" VerticalOptions = "FillAndExpand">
               <Grid.Children>
               </Grid.Children>
            </Grid>
         </ScrollView>
      </Frame>
      <Frame x:Name="bottom_frame" HasShadow="true" OutlineColor="Green" Padding="5,5,5,5" VerticalOptions = "FillAndExpand">
         <ScrollView x:Name="bottom_scroll_view" VerticalOptions = "FillAndExpand">
            <Label  Text="..." XAlign="Start" YAlign="Start" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" x:Name="bottom_label" LineBreakMode="WordWrap" />
         </ScrollView>
      </Frame>
      <StackLayout x:Name="bottom_stack_layout" Orientation="Horizontal">
         <Button Text="Add 1" x:Name="button_1"></Button>
         <Button Text="Add 2" x:Name="button_2"></Button>
         <Button Text="http" x:Name="button_3"></Button>
         <Button Text="http 1" x:Name="button_4"></Button>
      </StackLayout>
   </StackLayout>

Viewing all 77050 articles
Browse latest View live


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