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

Problems when collapsing listview element in iOS


Not found type gridview

$
0
0

I try add gridview like in example on docs.microsoft, but VS says: this type not found.
What i doing wrong?
I jast need Grid with ItemsSource.

All of my data in my Observable collection is the same, how do I fix this?

$
0
0

Hey,

I have a binding to an ObservableCollection that keeps overwriting all the data in the collection with whatever is current when I attempt to add to the collection or whenever the current data itself is changed. I know there is a simple fix for this but I'm not sure what I am missing.

Localized App Name for Xamarin.iOS

Passing values between 2 opened pages

$
0
0

Hey, so in my application I am using Master and Detail page. When Detail page opens I will go to the Master (slides from the left side) and I check checkbox. I want that value pass to my Detail page. In debug mode I can see method clearly called and good value is there, but when it ends, nothing happens, can you help me?

private void Button_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
if (ckeck.IsChecked == true)
{
Page2 p2= new Page2 ();
p2.dajCheck("value", true);
}
else
{
Page2 p2= new Page2 ();
p2.dajCheck("spomenici", false);
}
}

This is send value from Master to Detail, is it a good way?
I can't find anything else...

THX! :-)

Linking not working

$
0
0

hey guys i am getting this error
I have a xamarin forms project with .netstandrad library version 2.0.
One api project with ef6 and that dll is included in xamarin forms project . When i am trying to make android build with linker enable.SDK only iam getting this error

System.InvalidCastException: Unable to cast object of type 'System.Byte' to type 'System.String'.

at Mono.Cecil.MetadataBuilder.GetConstantSignature(ElementType type, Object value)
at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
at Mono.Cecil.MetadataBuilder.AddField(FieldDefinition field)
at Mono.Cecil.MetadataBuilder.AddFields(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddTypeDefs()
at Mono.Cecil.MetadataBuilder.BuildTypes()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.ModuleWriter.b__0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
at Mono.Cecil.AssemblyDefinition.Write(String fileName)

Its happening on Oracle.ManagedDataAccess.dll
I tried with skipping this assembly.Tried with enabling proguard.

How can I setup icons in my menu?

$
0
0

Hello, I am working on a project that I would like to eventually try to release as an IOS app as well as android. I'm using the PCL code to build the bulk of my code, which is leading me to several issues.
One of which is simply this, the bulk if not all of my forms code is in the PCL project, which limits my form controls (annoying), but also means I cannot figure out how to add icons to my menu options for my master detail view.
I understand they have to be added in my platform specific code, but does this mean that I need to define and build all of my menus and forms in the platform specific area? I suppose this wouldn't be all that bad since it would also allow me to use the controls I want (editable spinner, autocomplete textbox, etc).
Am I just making this harder than it needs to be, by trying to build my forms in the PCL?

Thanks!

Where did Android SDK go?

$
0
0

I updated Visual Studio 2017 on Windows today, from v15.9.13 to v15.9.14 and now the Android tools are gone:

How can i get them back? Without those tools I can't archive my Android app.
Thanks!


Video shows white screen in android while working fine in iOS

$
0
0

Hi everyone just stuck in a issue where videoview is not showing the video but audio is coming and in ios its working fine and if i change the droid VideoRenderer (videovie.SetZOrderOnTop(true)) than video come above all the views and i am not than able to use even play/pause button

Where is $(MSBuildExtensionsPath) located?

$
0
0

When creating a iOS Library porject and opening the csproj file I see <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> in the bottom. What is $(MSBuildExtensionsPath)and what is location of it?

how to make our WebView only show youtube video instead of entire page of youtube

$
0
0

i have webview in list and i'm showing youtube videos as per list of article have in my app but user can able to see whole entire page of youtube and they can search another videos too. i just wanted the they should able to see just youtube video rather than entire page?
please help

MapRenderer OnMapReady event equivalent for iOS ?

$
0
0

I need an equivalent event for an iOS renderer:

public class MyMapRenderer : Xamarin.Forms.Maps.Android.MapRenderer
{
    ...

    protected override void OnMapReady(GoogleMap map)
    {
        base.OnMapReady(map);

        // need to do things here
    }

    ...
}

Thanks

ListView gets refreshed only after I scroll after updating an item

$
0
0

Hello,

I am creating a shopping cart app and I am stuck in between with Listview refresh. I have a view cell in my list view and it has a Image button. When I click on the image button based on the model parameter(bool) I am replacing the image. After I update the model property, my listview is not getting refreshed automatically. Refresh happens only after I scroll the ListView.

Is there anything I am missing in below code?

Code: View cell in listview-

                         <ImageButton

                                            Grid.Row="0"

                                            Grid.Column="1"

                                        Margin="5,10,10,5"

                                        Aspect="AspectFit"

                                        BackgroundColor="Transparent"

                                        Command="{Binding Path=BindingContext.CartCommand, Source={x:Reference product}}"

                                        CommandParameter="{Binding .}"

                                        HorizontalOptions="End"

                                        Source="{Binding WishListImageIcon}"

                                        VerticalOptions="Center" />

View model:

public ICommand CartCommand { get; private set; }

private void UpdateCartImage(Electronics electronic)

        {

            if (electronic.WishList)

            {

                electronic.WishList = false;



            }

            else

            {

                electronic.WishList = true;



            }



            int pos = ElectronicList.IndexOf(electronic);

            ElectronicList.RemoveAt(pos);

            ElectronicList.Add(electronic);

        }

Model:

public bool WishList

        {

            get { return _wishList; }

            set { SetValue(ref _wishList, value); }

        }



        public string WishListImageIcon

        {

            get { return WishList ? "icon_wish_click.png" : "icon_wish_unclick.png"; }



        }

I am new to Xamarin. Kindly help me to resolve the issue.

Thanks,
Prasanna

Error while parsing timestamp in GCM

$
0
0

07-18 17:22:37.347 W/FirebaseMessaging(18679): Error while parsing timestamp in GCM event
07-18 17:22:37.347 W/FirebaseMessaging(18679): java.lang.NumberFormatException: s == null
07-18 17:22:37.347 W/FirebaseMessaging(18679): at java.lang.Integer.parseInt(Integer.java:577)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at java.lang.Integer.valueOf(Integer.java:801)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at com.google.firebase.messaging.zzd.zzb(Unknown Source:60)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at com.google.firebase.messaging.zzd.zzh(Unknown Source:84)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at com.google.firebase.messaging.FirebaseMessagingService.zzo(Unknown Source:35)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at com.google.firebase.iid.zzf.zza(Unknown Source:38)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at com.google.firebase.iid.zzh.zzcfv(Unknown Source:80)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at com.google.firebase.iid.zzh.zza(Unknown Source:29)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at com.google.firebase.iid.FirebaseInstanceIdInternalReceiver.onReceive(Unknown Source:41)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at android.app.ActivityThread.handleReceiver(ActivityThread.java:3380)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at android.app.ActivityThread.access$1200(ActivityThread.java:200)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1662)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at android.os.Handler.dispatchMessage(Handler.java:106)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at android.os.Looper.loop(Looper.java:193)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at android.app.ActivityThread.main(ActivityThread.java:6692)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at java.lang.reflect.Method.invoke(Native Method)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
07-18 17:22:37.347 W/FirebaseMessaging(18679): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
07-18 17:22:37.349 W/FirebaseMessaging(18679): Unable to log event: analytics library is missing

Custom Control With ICommand Property Not Working

$
0
0

Hi there!

I created a simple custom control (Inherited from ContentView) for learing purposes. The control has two custom properties: Text and Command. When I use this custom control with a page test, the property Text works, but Command doesn't.

What is wrong with my code?

Many thank for any kind of help.

This is my custom control (MyCustomControl.xaml):

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             x:Class="ReusableUserControls.MyCustomControl">

  <ContentView.Content>

    <StackLayout>

      <Entry x:Name="myEntry" Placeholder="enter something" />

      <Button x:Name="myButton" Text="Ok" />

    </StackLayout>

  </ContentView.Content>
</ContentView>>

With the following code behind (MyCustomControl.xaml.cs):

using System;
using System.Windows.Input;
using Xamarin.Forms;

namespace ReusableUserControls
{
    public partial class MyCustomControl : ContentView
    {
        public MyCustomControl()
        {
            InitializeComponent();
            //
            this.myButton.Clicked += (object sender, EventArgs e) =>
            {
                Execute(Command);
            };

            this.myEntry.TextChanged += (object sender, TextChangedEventArgs e) =>
            {
                Text = e.NewTextValue;
            };
        }

        public static readonly BindableProperty TextProperty =
            BindableProperty.Create(nameof(Text),
                                    typeof(string),
                                    typeof(MyCustomControl),
                                    "",
                                    BindingMode.TwoWay,
                                    propertyChanged: (BindableObject bindable, object oldValue, object newValue) =>
                                    {
                                        var thisView = bindable as MyCustomControl;
                                        if (thisView == null) return;
                                        //
                                        thisView.Text = (string)newValue;
                                    });
        //
        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); this.myEntry.Text = value; }
        }

        public static readonly BindableProperty CommandProperty =
            BindableProperty.Create(nameof(Command),
                                    typeof(ICommand),
                                    typeof(MyCustomControl),
                                    null);
        //
        public ICommand Command
        {
            get { return (ICommand)GetValue(CommandProperty); }
            set { SetValue(CommandProperty, value); }
        }

        // Helper method for invoking commands safely
        public static void Execute(ICommand command)
        {
            if (command == null) return;
            if (command.CanExecute(null))
            {
                command.Execute(null);
            }
        }

    }
}

To test MyCustomControl, I created the following page: (CustomControlTestPage.xaml)

 <?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:ReusableUserControls;assembly=ReusableUserControls"
             x:Class="ReusableUserControls.CustomControlTestPage">

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

  <ContentPage.BindingContext>
    <local:MyCustomControlViewModel />
  </ContentPage.BindingContext>

  <StackLayout Spacing="10">

    <!-- THE COMMAND ASSIGN TO CUSTOM CONTROL DOESN'T WORK -->
    <local:MyCustomControl Text="{Binding Nome}" Command="{Binding ProcessCommmand}" />

    <!-- THE COMMAND ASSIGN TO BUTTON'S PAGE WORKS -->
    <Button Text="This button works" Command="{Binding ProcessCommand}" />

  </StackLayout>

</ContentPage>

Here is the ViewModel class (MyCustomControlViewModel.cs):

namespace ReusableUserControls
{
    public class MyCustomControlViewModel : ViewModelBase
    {

        string _nome;
        public string Nome
        {
            set { SetProperty(ref _nome, value); }
            get { return _nome; }
        }

        public ICommand ProcessCommand { get; set; }

        public MyCustomControlViewModel()
        {
            ProcessCommand = new Command(ProcessCommandExecute);
            Nome = "1, 2, 3 testin...";
        }

        private void ProcessCommandExecute(object obj)
        {
            // Just to test the command binding
            var a = 1;
        }
    }
}

I cant seem to deploy a local build on my iPhone with VS 2019

$
0
0

I recently downloaded and installed Visual Studio 2019 to run my Xamarin Forms project. I added my apple user to the Visual Studio options and downloaded all the provision profiles. I also right clicked properties on the iOS project and verified that my apple cert and profile show. Then I connect to my mac host and attempt to deploy to my iPhone (which worked before)...and the error I get is "Could not find any available provisioning profiles for iOS". I triple checked and made sure my device, cert and provision are all connected and are all good and they are. Is anyone else having issues with this on Visual Studio 2019?

How to pass date through body in put

$
0
0

public IHttpActionResult PutUpdateDate(string name, int no, [FromBody]DateTime date)
{
//some code here
}

How to pass date through body.

Why my pins on android are lost ?

$
0
0
Hi all,
On ios my pins are correctly set.
But on android (with google maps) ou pins are drugs like this :

Embedding a custom Content View in another xaml - Exception: System.InvalidCastException: Specified

$
0
0

Hi,
I've created my own C# content view class with XAML using the "Add Item" menu option in Visual Studio.

I try to embed this content view into a the xaml of a Page class and at runtime the InitializeComponent() method in my ContentView's View.g.cs file throws
and exception "Exception: System.InvalidCastException: Specified" on the following line of code:

    private void InitializeComponent() {
        global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(TextFieldViewV1));          <<---- THIS THROWS EXCEPTION
        xxamFieldValueEntry = global::Xamarin.Forms.NameScopeExtensions.FindByName<global::Xamarin.Forms.Entry>(this, "xxamFieldValueEntry");
    }

The XAML for my Content View "TextFieldViewV1" is trivial:


<ContentView.Content>



</ContentView.Content>

I include the namespace of the content view in the Xaml of my test page and the project compiles without errors.

Possible to update Label.Text *before* display?

$
0
0

I have a view that is essentially a popup window. The view "opens" and "closes" simply by toggling IsVisible. The view contains several labels whose contents change each time the view becomes visible. I am updating the Label.Text fields before setting IsVisible on the parent view. However, there is a noticeable flash after the view becomes visible as the labels are still changing to their new text values. Is there anyway to avoid this and ensure that the new values are fully updated before the view becomes visible?

Thanks in advance for any input!

Viewing all 91519 articles
Browse latest View live


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