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

MasterDetailPage IsPresented is completely ignored.

$
0
0

Two issues:

(1) If I set IsPresented = true on the OnAppearing() method of my MasterDetailPage, the Master menu is shown and then is immediately closed automatically. A video showing the Master closing on load: https://dl.dropboxusercontent.com/u/11453596/Videos/masterClosing.mov

    protected override void OnAppearing()
    {
        base.OnAppearing();
        IsPresented = true;
    }

(2) If I set IsPresented = true anywhere else, nothing happens at all.

I'm using Xamarin.Forms 1.3.0.6292. Any idea?


public class HomePage : MasterDetailPage
{
    public HomePage()
    {
        Detail = new Detail();
        Master = new ContentPage() {
            Title = "Master...",
            Content = new Label {
                    Text = "Master..."
            }
        };

        IsGestureEnabled = false;
    }

    protected override void OnAppearing()
    {
        base.OnAppearing();
        IsPresented = true;
    }
}

public class Detail : ContentPage
{
    public Detail()
    {
        var bt = new Button() {
            Text = "Drawer"
        };
        bt.Clicked += (sender, e) => App.Master.IsPresented = true;

        Content = bt;
    }
}

Any solution for OAuth FB/Google without webviews

$
0
0

Hello all,

I'm developping an app in which I'd like the user to log with fb or google account. So far I've been using Xamarin Auth which provides a OAuth authentification with webviews.

As I want to realease the app on markets, I checked the future deprecation of this component. Google made an annoucement saying that they will block any OAuth in webviews from April 20th 2017 ...

Have you find a solution to Xamarin Auth for google sign in ?

I've seen a component for FireBase published by xamarin 25 days ago ... but I wonder if it will work for forms as it is a xamarin android component ... And I'd like to keep the logic that "forms is crossplatform" and I do not want to use a plugin for each project.

And I do not want to keep xamarin auth only for Facebook, as I'm sure that they will apply the same policy as google in the future for webviews auth (for all reasons they gave)

I've been seeking the web but no solutions...

I'm glad if someone's found something or a workaround without components if there are none ..

Cheers.

How Display Static Data in CarouselView in Xamarin Forms

Once IsGestureEnabled is set to false, setting it to true again doesn't have any effect on iOS

$
0
0

I need to toggle the value of my MasterDetailPage property of "IsGestureEnabled" when opening and closing its Master page. To accomplish this, I have an event handler to change the value of this property...

 this.IsPresentedChanged += ((object sender, EventArgs args) =>
            {
                System.Diagnostics.Debug.WriteLine("==> IsPresentedChanged event, this.IsPresented = {0}", this.IsPresented);
                this.IsGestureEnabled = this.IsPresented;
            });

This event handler works as expected, however, once I change the IsGestureEnabled property to false, setting it to true again doesn't have any effect on iOS. I think this is a Xamarin bug since I'm not the only one experiecing this issue (see here).

Is there a workaround for this?

Thanks.

CultureInfo.CurrentCulture always returns 'en-US' in iOS 11

$
0
0

I've noticed that in iOS 11 the value of System.Globalization.CultureInfo.CurrentCulture always seems to return 'en-US' regardless of the language actually set on device. I never saw this issue with iOS 10 (that is it always returned the language of the device) so I'm not sure if this is a bug or some other change under iOS 11.

Why is the setter of a binding property called for a Stepper?

$
0
0

I'm building an app in Xamarin.Forms in which I want to use a Stepper. I'm using MVVM so I bind the value of the stepper to a value in my model. The stepper is in a (self build) collapsable listview. When a cell is decollapsed it will show the stepper. At the moment the stepper is shown on screen, the "Set" function of the binded property is called. I don't understand why. Shouldn't it call the "Get" function if it wanted to know the current value? Fun fact is that when the corresponding property is "0", the "Set" function is not called when the Stepper is shown on screen. When loading a label the "Get" function is nicely called.

Why is this and how can I solve the problem that I want to call a function to update a database via an api when the stepper is clicked/value is changed? I want to do it the MVVM way, of course I can do it in the code behind but I don't prefer that.

I currently use a different property for the stepper then the actual property with the value, as the value is set in different ways(also when loading from the API) and I don't want the loop that I load something and it updates the value immediately. I tried with the same property as well, but the same problem persists.

XAML
<Stepper x:Name="PredictionStepper" Minimum="0" Increment="1" Value="{Binding PredictionStepper}" IsVisible="{Binding PredictionCanBeAltered}" />

Model
public int PredictionStepper
{
get
{
return Prediction;
}
set
{
Prediction = value;
UpdateManager.Instance().Add(this);
}
}

    public int Prediction 
    { 
        get
        {
            return Prediction;
        }
        set
        {
            Prediction = value;
            OnPropertyChanged("Prediction");
        }
    }

How to handle different screen sizes

$
0
0

Hi,

are there any tutorials for xamarin forms on how to handle different screen sizes for iOS, Android and Windows Phone 8 ?
The only tutorials I could found was about apple and android watch.

SearchBar Cancel Button not visible when Text is empty

$
0
0

Using Forms version 2.0.
When the SearchBar receives focus and the Text is empty, the Cancel button is not visible. Only when Text is non-empty the Cancel button is displayed.
Therefor you can not dismiss the keyboard when Text is empty. I think the Cancel button should always be visible when the SearchBar has focus.
I have a workaround that puts a space in the Text property when it's emptied but thats far from ideal.


How to implement native android xaml file in Xamarin.Forms?

$
0
0

I can't use xaml file, which contains native android code in my Xamarin.Forum project as variable.

Hybridwebview iOS url not loading

$
0
0

I have implemented the hybridwebview as per the document. Android and UWP works fine. iOS when url are is provide nothing is show in hybridwebview.
I have SET NSAppTransportSecurity also.

Please help

DatePicker FontSize, etc.

$
0
0

There doesn't seem to be any easy way to change the textview's for DatePicker/TimePicker. Has anyone found a way to either turn a label into a datepicker or write a custom renderer that will customize the look of the datepicker. In particular I care about Android first and foremost.

Attempting to JIT compile method

$
0
0

iOS app, using a .NET standard library. And using EntityFramework for SQLite.
The iOS app calls a routine to add an entity into a table:

msg = new QTNC.NETStandard.Models.Message();
msg.Received = DateTime.Now.ToUniversalTime();
msg.Created = DateTime.Parse(messageReceived["Created"]);
msg.Body = messageReceived["body"];
msg.HtmlBody = messageReceived["HtmlBody"];
msg.Title = messageReceived["title"];
msg.ProductName = messageReceived["ProductName"];
msg.TextColor = messageReceived["TextColor"];
msg.BackgroundColor = messageReceived["BackgroundColor"];
msg.Id = Guid.Parse(messageReceived["Id"]);
msg.Read = DateTime.Now;
database.Messages.Add(msg);
database.SaveChangesAsync();
return msg;

And message is defined as:

public class Message
{
[Key]
public Guid Id { get; set; }
public string ProductName { get; set; }
public string Title { get; set; }
public string Body { get; set; }
public DateTime Received { get; set; }
public DateTime Read { get; set; }
public DateTime Created { get; set; }
public string HtmlBody { get; set; }
public string TextColor { get; set; }
public string BackgroundColor { get; set; }
}

The error happens on the database.Messages.Add(msg);

Attempting to JIT compile method '(wrapper runtime-invoke) :runtime_invoke_void__this___Guid_object_object_DateTime_object_object_DateTime_DateTime_object_object (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.

the Read property btw was nullable at first, and interestingly the error was almost the same but was referring to a DateTime then as well.

And BTW, the link mentioned in the error (https://developer.xamarin.com/guides/ios/advanced_topics/limitations/) does not exist....

And a question on the side:
msg.Received = DateTime.Now.ToUniversalTime();
msg.Created = DateTime.Parse(messageReceived["Created"]);

messageReceived["Created"] is a string that contains a UTC time ,
but if I look at the value of msg.Created it shows me that value in localtime, why? (msg.Received shows the UTC time)

ToolbarItem Effect for custom font

$
0
0

I am attempting to create an effect that will style the ToolbarItem and give it a custom font. My breakpoint hits the PCL code, but it never seems to venture into the OnAttached() override. I am wondering if there is something that I am missing. Do I have the ability to effect the actual styling on Navigation ToolbarItems?

iOS Effect Code

[assembly:ResolutionGroupName ("Core")] 
[assembly:ExportEffect (typeof(ToolbarItemEffect), "ToolbarItemEffect")] 
namespace Core.iOS.Effects 
{ 
    public class ToolbarItemEffect : PlatformEffect 
    { 
        protected override void OnAttached() 
        {
            var style = new UIStringAttributes 
            { 
                Font = UIFont.FromName("FontName", 24)
            }; 

            var navigationBar = (UINavigationBar) Control; 
            navigationBar.TitleTextAttributes = style; 
        } 

        protected override void OnDetached() 
        { 
        } 
    } 
}

Shared Code

    public class ToolbarItemEffect : RoutingEffect 
    { 
        public ToolbarItemEffect() : base("Core.ToolbarItemEffect") 
        { 
        } 
    }

Xaml on Navigation Page

<ContentPage.ToolbarItems>
    <ToolbarItem Text="Text" Command="{Binding TextCommand}">
        <ToolbarItem.Effects>
            <core:ToolbarItemEffect />
        </ToolbarItem.Effects>
    </ToolbarItem>--> 
</ContentPage.ToolbarItems>

How to customize items of picker in Xamarin.forms as there is no ItemTemplate

$
0
0

How we can customize items of Picker in Xamarin.Forms. I am not able to find ItemTemplate property in Picker.

If you are going to answer it like 'Use ListView', then please mention how can we make selection in ListView same as Picker.Because selection in Picker and ListView is completely different.

Any help is apprenticed.

For Example I want to display Picker like that...

Problems with Xamarin Android support packages

$
0
0

Every time is the same nightmare, I have my app that works fine.
Today I just need to remove a package. Like a lot of time, it was a mess.

I remove the plugin.toast. Android project stop to build, with a lot of errors, in xml files.

Tried everything. Remove xamarin forms package, changing target framework, delete nuget cache, I don't want to be boring.

But now, the project simply doesn't build. Frustrating.

Now the error is:

Severity Code Description Project File Line Suppression State
Error This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ....\packages\Xamarin.Android.Support.Annotations.26.1.0.1\build\MonoAndroid80\Xamarin.Android.Support.Annotations.targets. Timeout.Android

Obviously if I restore packages Visual studio tell me:

All packages are already installed and there is nothing to restore.
Time Elapsed: 00:00:00.1067208
========== Finished ==========

The problem is that I changed the target framework reverting it back to V7, but for a reason that I don't know the proj file of Android was not cleaned, and it contains some directory that will never be satisfied making the project broken.

I was able to solve this specific problem, after some hours of temptative, manually editing the csproj file removing the references that was impossibile to satisfy. But I'm not really confident about the depencies of the other packages, keeping them aligned and safe it's responsibility of nuget!

And in my experience, EVERY time I have to update the packages of a complex solution, something is wrong, and I have to loose a lot of hours trying to solve problems that was created from the updater itself.

I think that the bigger problem is related to the Android support version packages, that when was not updated correctly broke the project file, but I have the feeling that something was not working properly in this process and this is really dangerous for every developer that want to assure a seriously productivity for its work.


“LinkAssemblies task failed unexpectedly” in Android Realease seems to be caused by Xamarin.iOS.dll

$
0
0

I'm trying to compile my multiplatform Xamarin Forms App Android in Realease Mode but, after the last Xamarin Forms update to v2.5.0.122203, it doesn't compile and in output I have this error:

error MSB4018: The "LinkAssemblies" task failed unexpectedly. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: Mono.Linker.MarkException: Error processing method: 'System.Void ObjCRuntime.Runtime::set_UseAutoreleasePoolInThreadPool(System.Boolean)' in assembly: 'Xamarin.iOS.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void System.Threading._ThreadPoolWaitCallback::SetDispatcher(System.Func2<System.Func1,System.Boolean>) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue() 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: --- End of inner exception stack trace --- 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue() 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessEntireQueue() 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.Process() 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.Process(LinkContext context) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute() 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

It is not so readable but in the second row of this error I get:

Mono.Linker.MarkException: Error processing method: 'System.Void ObjCRuntime.Runtime::set_UseAutoreleasePoolInThreadPool(System.Boolean)' in assembly: 'Xamarin.iOS.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void System.Threading._ThreadPoolWaitCallback::SetDispatcher(System.Func2<System.Func1,System.Boolean>)

In Debug Mode I have no problems.

Did someone else encounter the same error?

Crash trying to debug wirelessly

$
0
0

I have no idea what changed. I started up my machines today and when I try and deploy wirelessly I get this crash output:

Application bundle 'com.myapp' installed on 'RealPhone's 6S'
Launching...
2018-03-20 21:27:22.756 mlaunch[5582:4452104] Threadpool worker DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-13760/DTDeviceKitBase/DTDKRemoteDeviceConnection.mm:968
Details: Failed to start Instruments daemon on device “c92f65c8ad6d40acf4dd10226b61e4890ce46d4c”: Error Domain=com.apple.dtdevicekit Code=-402653083 "Could not connect to the device." UserInfo={NSLocalizedDescription=Could not connect to the device., com.apple.dtdevicekit.stacktrace=(
0 DTDeviceKitBase 0x000000010dd68fed DTDKCreateNSError + 113
1 DTDeviceKitBase 0x000000010dd69831 DTDK_AMDErrorToNSError + 1135
2 DTDeviceKitBase 0x000000010dd7ae8f __63-[DTDKRemoteDeviceConnection startFirstServiceOf:unlockKeybag:]_block_invoke + 300
3 DTDeviceKitBase 0x000000010dd7a521 __48-[DTDKRemoteDeviceConnection futureWithSession:]_block_invoke_3 + 22
4 DTDeviceKitBase 0x000000010dd6b815 __DTDKExecuteInSession_block_invoke_2 + 35
5 DTDeviceKitBase 0x000000010dd6ac1f __DTDKExecuteWithConnection_block_invoke_2 + 474
6 DTDeviceKitBase 0x000000010dd6aa1a __DTDKExecuteWithConnection_block_invoke + 111
7 libdispatch.dylib 0x00007fff622fcd50 _dispatch_client_callout + 8
8 libdispatch.dylib 0x00007fff62313781 _dispatch_sync_invoke_and_complete_recurse + 65
9 libdispatch.dylib 0x00007fff6231321a _dispatch_sync_wait + 585
10 DVTFoundation 0x000000010c9376f0 DVTDispatchBarrierSync + 213
11 DVTFoundation 0x000000010c910c7a -[DVTDispatchLock performLockedBlock:] + 75
12 DTDeviceKitBase 0x000000010dd6a915 DTDKExecuteWithConnection + 231
13 DTDeviceKitBase 0x000000010dd6b681 DTDKExecuteInSession + 381
14 DTDeviceKitBase 0x000000010dd7a458 __48-[DTDKRemoteDeviceConnection futureWithSession:]_block_invoke_2 + 119
15 DVTFoundation 0x000000010c936a4f __DVTDispatchAsync_block_invoke + 806
16 libdispatch.dylib 0x00007fff62304591 _dispatch_call_block_and_release + 12
17 libdispatch.dylib 0x00007fff622fcd50 _dispatch_client_callout + 8
18 libdispatch.dylib 0x00007fff6231120c _dispatch_queue_serial_drain + 635
19 libdispatch.dylib 0x00007fff623040fd _dispatch_queue_invoke + 373
20 libdispatch.dylib 0x00007fff62311f02 _dispatch_root_queue_drain_deferred_wlh + 332
21 libdispatch.dylib 0x00007fff62315d16 _dispatch_workloop_worker_thread + 880
22 libsystem_pthread.dylib 0x00007fff625c1033 _pthread_wqthread + 980
23 libsystem_pthread.dylib 0x00007fff625c0c4d start_wqthread + 13
), NSLocalizedRecoverySuggestion=Could not connect to the device., NSLocalizedFailureReason=Could not connect to the device.}
Object:
Method: -instrumentsConnection
Thread: {number = 11, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
warning MT1043: Failed to launch the application using the instruments service. Will try launching the app using gdb service.
Launching 'com.myapp' on the device 'RealPhone's 6S'
Launching /private/var/containers/Bundle/Application/5F381836-A11F-4954-A187-DCFD18B12BC5/myapp.app -monodevelop-port 10000 -connection-mode wifi

If you leave it at this point nothing happens. Eventually the debugger detaches and nothing runs. Luckily things seem to work over USB.

XAML: Disabling a button when ListView.SelectedItem property is NULL

$
0
0

Hi,

I want to disable a button when SelectedItem property of ListView is null. I tried this:

<Button Clicked="myButton_Clicked" Image="ic_image" x:Name="myButton">
    <Button.Style>
        <Style TargetType="Button">
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=myListView, Path=SelectedItem}" Value="{x:Null}">
                    <Setter Property="IsEnabled" Value="false" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Button.Style>
</Button>

The app has a login page and a main page. Login credentials are stored on the device. If everything goes well, main page appears otherwise login page appears.

If I comment out this part:

                ...
                <DataTrigger Binding="{Binding ElementName=myListView, Path=SelectedItem}" Value="{x:Null}">
                    <Setter Property="IsEnabled" Value="false" />
                </DataTrigger>
                ...

main page appears but if I uncomment that part, login page appears. I think that part causes an error but the IDE (VS Mac) doesn't throw it. Could anyone help me?

Thank you...

Your project is not referencing the ".NETPortable,Version=v4.6,Profile=Profile44" framework. Add a r

$
0
0

I can't build my Xamarin.Forms project after I did a commit on it from Visual Studio for mac. now I keep getting this error, no matter what target do I choose:

Your project is not referencing the ".NETPortable,Version=v4.6,Profile=Profile44" framework. Add a reference to ".NETPortable,Version=v4.6,Profile=Profile44" in the "frameworks" section of your project.json, and then re-run NuGet restore.

Feature to disable in Production and made to be available only when user clicks on some image/logo

$
0
0

Hi,

In login screen I have list of environments , while generating production builds I need to make this environments invisible to the end user and I need to enable them only on double click of on some instance.

Can any one suggest how to implement the same ??
Thanks in advance,

Viewing all 77050 articles
Browse latest View live


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