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

Xamarin - cocossharp freeze after lock/unlock

$
0
0

Good Morning,

I'm testing xamarin android. my app use cocossharp to animate some objects. When I put my app in the background and return it continues to function normally.

Add a video (link). As you can see, you can move a blank sheet that is a cocossharp feature, when you put the application in the background and get back to working normally:

https://drive.google.com/open?id=1PrJttcMgZFdtL9xfKHBaXajNpnns5s33

Now please note this other video. This is working normally, including the cocossharp features. When locking and unlocking the app the cocossharp features freeze:

https://drive.google.com/open?id=1945OSvc9VM833B1iQiYlq6j7temC2cVT


why collectionview's load data incrementally not start from the data added?

$
0
0

RemainingItemsThreshold can load data if user read to end of the data.
but when I add the data it will reset the datasource and the collectionview will show from the start not the end.why?

backup sqlite database to Google drive

$
0
0

Is there a way to backup sqlite database to Google drive. If anyone have an idea please help me

Bind Google spreadsheet

$
0
0

Does any one has an example how to bind Google spreadsheets to a listview ?

Xamarin.iOS project: CS1703: Multiple assemblies with equivalent identity have been imported

$
0
0

I've got a cross platform (iOS and Android) Xamarin solution using .NET Standard 2.0. The solution is being built by Visual Studio 2017 (I've tried both the current and preview versions). The Forms and Android projects build fine. However, the iOS fails to build, with the following error:

1>CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\newuser.nuget\packages\system.reflection.emit\4.3.0\ref\netstandard1.1\System.Reflection.Emit.dll' and 'C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Reflection.Emit.dll'. Remove one of the duplicate references.

I've tried many work arounds as described here:

oren.codes

www.hanselman.com

github.com/NuGet

Unfortunately none of these suggestions work. I have also tried to add the System.Reflection.Emit nuget package directly to the Forms and/or to the iOS projects directly. This doesn't work either. Note that originally, the The System.Reflection.Emit package wasn't referenced directly by anything in the solution. It is being pulled in by the following nuget packages which are being explicitly referenced:

  • Acr.DeviceInfo (5.0.5)
  • akavache (6.0.0-alpha0038)
  • AutoMapper (6.2.2)
  • Microsoft.Identity.Client (1.1.1-preview0040)
  • Newtonsoft.Json (10.0.3)

Finally, I have tried the update-package -reinstall command in the package console to reinstall all packages for the iOS project. This doesn't work either.

-- update

Just to make this clear, neither the Xamarin Forms or the Xamarin iOS project directly reference System.Reflection.Emit. That package is being pulled in as a dependency of other nuget packages, just from packages that are installed into the Xamarin Forms project. I have confirmed all of the dependencies that are referenced by Nuget, are using the same version. See these screenshots:

Referenced Emit dependencies from Visual Studio
Expanded referenced Emit dependencies

It seems to me that the problem (as the error says) is that there is an old version of System.Reflection.Emit that was installed by Visual Studio. However, I can't find a way of ignoring it and using the version of System.Reflection.Emit instead. As I've said above, I have tried to use a project.json file in the Xamarin.iOS project, and manually ignoring, but this doesn't work.

Does anyone else have any ideas?

As an aside, I notice that this bug is still open for Xamarin.

Xamarin Bugs

FYI: I have added this question to Stackoverflow as well.

iOS ImageRenderer CreateNativeControl error

$
0
0

I am trying to implement a custom ImageRenderer in iOS subclassing the native UIImageView, but I am having some problems with CreateNativeControl.

In the older Xamarin.Forms version (like 4.2) the custom native class that I initialized with protected override UIImageView CreateNativeControl() { return new NativeImage(); } looks like it never get called (the message I log in the constructor is not shown). The Custom Renderer is correctly initialized (the right message is logged).

In the latest stable version (like 4.4) in overriding of CreateNativeControl the return type it is said that has to be a FormsUIImageView, never heard of it, anyway I also tried to subclass that but same problem as before, it seems it never get called as the constructor message is not logged. The Custom Renderer is correctly initialized (the right message is logged).

Here the code I used:

`public class IOSImageView : ImageRenderer
{
public IOSImageView()
{
}

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

        if(Control == null)
        {
            return;
        }

        Console.WriteLine("PIPPO created from Custom Renderer");  //this message is correctly logged
    }


    protected override UIImageView CreateNativeControl()  //FormsUIImageView  in XF 4.4
    {
        return new NativeImage();
    }

}

public class NativeImage : UIImageView  //FormsUIImageView in XF 4.4
{
    public NativeImage() : base()
    {
        Console.WriteLine("PIPPO created from native IOS");  //this message is NOT logged
    }

public override void TouchesBegan(NSSet touches, UIEvent evt)
    {
        base.TouchesBegan(touches, evt);
        Console.WriteLine("PIPPO touched");  //this (of course because no NativeImage is shown and there is no image to touch) is NOT logged
    }
}

}`

How to know the page is showed?

$
0
0

As I am loading big data to collectionview,it tells me onLayout time is too long. So I want to not set the bindingcontext until the page is showed.
I will give a loding message until the load is complete.

I know there is a OnAppearing methods to ovveride,but is there a OnAppeared methods? to tell me the page is completely shown?

How to manage focused element on AndroidTv

$
0
0

Hello,

i'm working on a small app for a Tv where i list all videos available on my private server. I want to display a grid of thumbnail and when I click on one I open the video.

Here is how I display the thumbnail :

`<?xml version="1.0" encoding="utf-8" ?>

<StackLayout Padding="10">
    <CollectionView ItemsSource="{Binding Videos}">
        <CollectionView.ItemsLayout>
            <GridItemsLayout Orientation="Vertical" Span="3" HorizontalItemSpacing="10" VerticalItemSpacing="10"/>
        </CollectionView.ItemsLayout>
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <StackLayout Orientation="Horizontal" BackgroundColor="Beige" HeightRequest="50">
                    <!-- thumbnail and title are displayed here -->
                </StackLayout>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>

</StackLayout>


`
Everything work fine but I would like to be able to navigate through all items and select one using my remote and not by touching the screen.


Shell - IsVisible

$
0
0

I am new to using Shell and Xamarin forms in general. I watched a presentation where shell items could be hidden using the property IsVisible but I can't find any documentation on that feature. I have installed the latest pre-release NuGet to see if it was on the up and coming but it's not coming up via IntelliSense in the XAML editor or when building my shell in c sharp there are is no IsVisible property.

I need to have a group of views with top tabs that can only be navigated to programmatically, I am open to other solutions to this use case.

How to fold the groupped collectionView?

$
0
0

I have a collectionView which is groupped and the data is too big.
I want to make the subitems not visible until I click the groupHeader.
How to do it?

I need Master Detail Page and Tabbed Page(bottom) at the same time in the application

$
0
0
When we set drawer screen layout as master and Tabbed Page as detail we can achieve this. But the problem is when i try to click on the menus in the drawer screen of master detail page, i loss the tabbed page navigation from bottom.

Local-Storage Gets cleared on Popping a Navigation Page.

$
0
0

Hi,

I am working on an app which uses "WKWebview"(ios customrenderer) to play embedded YouTube videos.
It has two navigation pages Page-1 and Page-2.
Page-1 is root page.

Page-1 contains : Wkwebview (To show advertisement video and this link always remains same) and ListView-1 (category links)
Page-2 contains : Wkwebview (To show videos) and ListView-2 (Actual video links)

It work like:


I am using Same WkWebview CustomRendere for both Pages.

Working on Simulator with ios version 12.0

When i visit page-1 it loads advertisement video and populate category links in **ListView-1 **. (Here it automatically stores https_www.youtube.com_0.localstorage, https_www.youtube.com_0.localstorage-wal and https_www.youtube.com_0.localstorage-shm) in local storage.

On clicking any item in ListView-1 it uses Navigation.PushAsync() to load Page-2 and shows corresponding Video links in ListView-2 and a video in Wkwebview corresponding to first video in ListView-2. And then we can choose any video and it displays quit well. (Here no we files are created in local storage, as they use existing files).

Problem:

On clicking the Back button of Page-2 following Message appears three times. (For https_www.youtube.com_0.localstorage, https_www.youtube.com_0.localstorage-wal and https_www.youtube.com_0.localstorage-shm)
[logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: /Users/ZZZ/Library/Developer/CoreSimulator/Devices/5BA-702-44C-9B-4465FA982/data/Containers/Data/Application/A1F-B71-1FA-A-D43BA9C/Library/WebKit/com.companyname.ZZZ/WebsiteData/LocalStorage/https_www.youtube.com_0.localstorage

When i looked in LocalStorage the files were actually deleted.

This happens only once when we navigate from Page-1 to page-2 and back for first time, if we perform the same repeatedly no message appears (even though files are still getting deleted.)

What Should i do?

SecTaskLoadEntitlements failed error=22 cs_flags=200

$
0
0

Hello,

When ever i execute my app on ios simulator first it shows this message before starting with other methods
SecTaskLoadEntitlements failed error=22 cs_flags=200
What does it means?
I have even not opened my Entitlements.plist.
Is it really an error to be bothered about.

could not signal service com.apple.webkit.webcontent: 113 could not find specified service

$
0
0

Hi,

I am working on an app which uses WKWebview to show YouTube Videos.
It plays Videos well, but when the page containing WKWebview is popped it shows following two messages:
could not signal service com.apple.webkit.webcontent: 113 could not find specified service
could not signal service com.apple.webkit.Networking: 113 could not find specified service
Kindly Help

Keyboard hide Entry after TranslateTo

$
0
0

I use TranslateTo to move a RelativeLayout. The parent of this layout is also RelativeLayout.
The keyboard hides the input field. But if I do not use TranslateTo, I init the layout in the end position, the keyboard works correctly.


How to hide the back button?

$
0
0

I want to set a titleview full of the title but there still will be a back button.how to hide it?
I am using Shell. and the titleview is Shell.TitleView

Is there a way to prevent a change to an Entry's Text property if newly entered value is invalid?

$
0
0

I have a numeric entry where I want to restrict the user from entering a value with more than 2 decimals. So if the user currently has "0.12" in the Entry, then types a 3, nothing happens and the value "0.12" remains in the field. I already have this working fine as far as what the user sees through the use of a Behavior that handles the TextChanged event of the Entry that will remove the last character of the Text property if there are more than 2 digits after the decimal.

However, the view model property bound to the Entry gets changed twice: once for user input of the 3rd decimal and once for when the Behavior changes the Entry's Text property. I do not want this to happen as the value of "0.123" immediately gets changed and should never be used, meaning that, ideally, the view model property gets changed zero times.

Is there a way to process the new value of "0.123" and prevent a change to the Entry's Text property altogether? My first thought would be to use a "TextChanging" event that can be canceled, but no such thing exists. In fact, not even the "PropertyChanging" event allows for this type of functionality.

Code Coverage of InitializeComponent on a page missing Blocks

$
0
0

My application is at application at 96% coverage including ViewModels, Models, and methods in the Views

VS19 Code Coverage reports that the not covered block count is 8 blocks for each page constructor InitializeComponent method.

I have 10 pages in the application, so 80 blocks total not covered. I am not sure what I can do to get the blocks covered, as I am so close to 100%, will be great to work out what I can do differently to get the blocks under coverage.

Example of an code behind, empty xaml, and UT that yields 8 blocks not covered:

public partial class AboutPage : ContentPage{
public AboutPage(){
InitializeComponent();
}
}

xaml:
Empty ContentPage, can't paste code here as it is suppressed.

Example of Test (nUnit)
[Test]
public void AboutPage_Constructor_Default_Should_Pass()
{
Assert.IsNotNull(new AboutPage());
}

Would appreciate actionable assistance to help me achieve the goal of 100% coverage.

Adding Languages that do not have a CultureInfo

$
0
0

Hi, I am developing an application that the customer wants translated in Luganda (ISO 639: lg). I am using the Multilingual App Toolkit and have been given an xlf file to use. The xlf file can be added fine, and a resx file generated from this.

Then in the app, I have attempted to switch my culture info to the language using code like this:

    var cultureInfo = CultureInfo.GetCultureInfo("lg");

    AppResources.Culture = cultureInfo;
    Thread.CurrentThread.CurrentCulture = cultureInfo;
    Thread.CurrentThread.CurrentUICulture = cultureInfo;
    CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
    CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

The problem is, I get a CultureNotFoundException when trying to get the culture info for "lg". I have a list of about 340 cultures supported, but not this one. Is there a way to add a culture info representing languages that arent supported by Microsoft to Xamarin projects?

I cant use the CultureAndRegionInfoBuilder because I am using the .net standard Xamarin.Forms which doesnt have this class.

I am also using app center which seems to have even less cultures built in as I had to change Portugese "pt-pt" to just "pt" for that cultureinfo

What are consequences/implications of using an ObservableCollection in this fashion?

$
0
0

This appears to allow me to do background work and when ready, supply the data to the collection and still get the UI to update with out a lot of fuss. Perhaps I am wrong as I am new at this. Having the option to set the flag means I can disable the "feature" when necessary (not even sure if that will be necessary but seemed easy enough to implement). Would this be a valid way to do background work and yet still update the UI?

```C#
//Override ObservableCollection with my own implementation
public class MYObservableCollection : ObservableCollection
{
public MYObservableCollection() : base()
{ }
public MYObservableCollection(IEnumerable collection) : base(collection)
{ }

​ public MYObservableCollection(List list) : base(list)
​ { }

​ ///


​ /// Boolean used to enforce adding, inserting, and removing of items on the main thread.
​ /// When set the three methods will only execute on the Main UI Thread, which ensures the UI
​ /// is updated when the CollectionChanged event occurs.
​ ///

​ public virtual bool EnforceMainThreadExecution
​ {
​ get;set;
​ }

​ ///


​ /// Inserts the item into the collection but checks to see if the thread is the Main UI thread or not.
​ /// If it is NOT the call to insert the item (base.InsertItem) is called on the Main UI thread.
​ /// If the EnforceMainThreadExecution flag is NOT set the call is made on the current running thread.
​ ///

​ ///


​ ///
​ protected override void InsertItem(int index, T item)
​ {
​ if (EnforceMainThreadExecution)
​ {
​ //Using
​ if (!MainThread.IsMainThread)
​ {
​ MainThread.BeginInvokeOnMainThread(() =>
​ {
​ base.InsertItem(index, item);
​ });
​ }
​ else
​ {
​ base.InsertItem(index, item);
​ }
​ }
​ else
​ {
​ base.InsertItem(index, item);
​ }
​ }

//These methods in the same way but removed for simplicity
protected override void SetItem(int index, T item){}

//These methods in the same way but removed for simplicity
protected override void RemoveItem(int index){}
}

//USAGE Example, (obviously it would have many other uses. In a view model of some page in my app):
public void HeaderTapped(object sender)
{
//Determine which button was pressed
int selectedIndex = -1;

​ ImageButton senderIButton = sender as ImageButton;

​ selectedIndex = expandedGroupsLocal.IndexOf(((MainMenuGroup)(senderIButton).CommandParameter));

​ if (selectedIndex > -1)
​ {
​ allGroupsLocal[selectedIndex].Expanded = !allGroupsLocal[selectedIndex].Expanded;
​ }

​ //update the menu in the background
​ System.Threading.Tasks.Task.Run(() => UpdateListContent());
​ }

​ private async System.Threading.Tasks.Task UpdateListContent()
​ {
​ bool retVal = false;

​ await System.Threading.Tasks.Task.Run(() =>
​ {
​ expandedGroupsLocal = new MYObservableCollection();
​ expandedGroupsLocal.EnforceMainThreadExecution = true;//Note the flag gets set here before I add items to the collection

​ foreach (MainMenuGroup group in allGroupsLocal)
​ {
​ MainMenuGroup newGroup = new MainMenuGroup(group.Title, group.ShortName, group.Expanded);
​ newGroup.MenuCount = group.Count;
​ if (group.Expanded)
​ {
​ foreach (MainPageMenuItem mnu in group)
​ {
​ //Add expanded group to menu
​ newGroup.Add(mnu);
​ }
​ }
​ expandedGroupsLocal.Add(newGroup);
​ }
​ });
​ return retVal;
​ }
```

Viewing all 81910 articles
Browse latest View live


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