Quantcast
Viewing all 81910 articles
Browse latest View live

PageContent Custome Renderer not working on Win8.1

I am trying to using a ContentPage CustomRenderer just like in the documentation and I get the following two errors:
1) CameraPageRenderer.OnElementChanged (VisualElementChangedEventArgs): no suitable method found to override
2) Argument 1: cannot convert from 'Xamarin.Forms.Platform.WinRT.VisualElementChangedEventArgs' to 'Xamarin.Forms.Platform.WinRT.ElementChangedEventArgs' CustomRenderer.WinPhone81

Changing the method signature to match the method in Xamarin.Forms.Platform.WinRT.PageRenderer which is
"OnElementChanged (ElementChangedEventArgs e)" doesn't help either.

I get the same error when I compile the official Custom Renderer Sample from Xamarin.Forms docs. I am using Xamarin.Forms v2.2.0.31 which is the version used in the sample as well Image may be NSFW.
Clik here to view.
:(
Any ideas


Get image from SharePoint 2010 library and display it in a webview

Hi,

I have web page content (Publishing HTML) that i get from a SharePoint 2010 library.

Everything is working fine except that the images are not showing up because SharePoint truncate the first part of the image URL (src=).

I tried to resolve the issue with a replace :

        content = content.Replace(@"src=""/", @"src=""https://site.mysite.com/");

        var htmlSource = new HtmlWebViewSource { Html = content };
        var browser = new WebView {Source = htmlSource};

        Content = browser;

When i check the image URL, everything is fine but the image is not displayed.

Any suggestions?

Label empty when updating model (Label inside ListView with ViewCell)

Here is code that does not work

Image may be NSFW.
Clik here to view.

public TestPage()
{
InitializeComponent();

this.BindingContext = this;

MyCollection = new ObservableCollection<MyModel>();
for (var i = 1; i <= 20; i++)
{
    MyCollection.Add(new MyModel());
}


ListView lv = this.FindByName<ListView>("testView");
lv.ItemsSource = MyCollection;

}

private void HandleButtonClicked(object sender, EventArgs e)
{
foreach (MyModel model in MyCollection)
model.Count = 10;
}

public ObservableCollection MyCollection { get; set; }

public class MyModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

private int _count;
public int Count
{
    get
    {
        return this._count;
    }
    set
    {
        this._count = value;
        this.OnPropertyChanged();
    }
}

}

How to approach push notifications on Xamarin.Forms project?

So we are working on a pcl project and have our UI set in a page inside the PCL. There is a scenario where our client wants some information to be sent as a push notification. We already have our UI in place and our backend too. We are using Azure to store data and have successfully configured WAMS. However we are scratching head on how to make push notifications work on Android without creating a separate page layout / controls that are android specific.

tl;dr - how do we use the PCL page UI elements to trigger push notifications on an Android device?

Pass binding from control to custom view "Sequence contains no matching element"

Hello,

everytime i try to bind the LabelText property in xaml from my custom cell i get the error "Sequence contains no matching element".
I really would like to make the binding via xaml work because i would like to do it without the x:name property and code behind.

controls:GridCell x:Name="Cell"
LabelText="{Binding ExampleText}" />

If i set the binding via code behind it works without any problems. Like this:

Cell.SetBinding(Cell.LabelTextProperty, "ExampleText");

My custom cell looks like this:

<cells:CellBase.View>
    <Grid HorizontalOptions="FillAndExpand"
          Padding="15, 15, 5, 5"
          VerticalOptions="FillAndExpand">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Label Grid.Column="0"
               BindingContext="{x:Reference Self}"
               HorizontalOptions="Start"
               Text="{Binding LabelText}" />
    </Grid>
</cells:CellBase.View>

the partial class to the GridCell

    public BindableProperty LabelTextProperty = BindableProperty.Create(propertyName: "LabelText",
                                                                returnType: typeof(string),
                                                                declaringType: typeof(GridCell),
                                                                defaultValue: string.Empty,
                                                                propertyChanged: OnLabelTextPropertyChanged);

    public GridCell()
    {
        InitializeComponent();
    }

    public string LabelText
    {
        get { return (string)GetValue(LabelTextProperty); }
        set { SetValue(LabelTextProperty, value); }
    }

    private static void OnLabelTextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
    {
        var gridCell = bindable as GridCell;
        gridCell.OnPropertyChanged("LabelText");
    }

Does anyone know how to solve this problem?
Or maybe is there any other way to expose an property from an Control on a custom view? The idea behind this view is to have an reusable cell that could later derive to an PickerCell, DatepickerCell, ... The derived cells only have to fill the second column of the grid and also expose its properties.

Regards
Malte

Xamarin.Forms Android app crashing due to XLabs Camera code after upgrade to Xamarin.Forms 2.2.0.31

When I say crashing, the app won't even start. To get it to run, I had to remove this line of code from my MainActivity OnCreate method. For those not familiar with the code, it is required for the XLabs Camera code to work properly.

#region Resolver Init
            SimpleContainer container = new SimpleContainer();
            container.Register<IDevice>(t => AndroidDevice.CurrentDevice);
            container.Register<IDisplay>(t => t.Resolve<IDevice>().Display);
            container.Register<INetwork>(t => t.Resolve<IDevice>().Network);

            Resolver.SetResolver(container.GetResolver());
            #endregion

Here is the error.

System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.OnPrepareOptionsMenu (IMenu menu) [0x00000] in :0
at Android.App.Activity.n_OnPrepareOptionsMenu_Landroid_view_Menu_ (IntPtr jnienv, IntPtr native__this, IntPtr native_menu) [0x00011] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:4301
at at (wrapper dynamic-method) System.Object:61b08371-c107-4c6e-bd8e-970af326d8bb (intptr,intptr,intptr)

Does anyone know a workaround for this? Any help is much appreciated. This was working just fine in Xamarin.Forms 1.5.0.6446. Without the camera working, I can't officially launch my Android app.

Storing to iCloud is deleted when the app is deleted?

I have some settings I would like to persist in iCloud if using iOS. The code has been very easy to implement. Recovering works fine too. However, if I delete the app, reinstall it, then try and get from iCould again, the data is not found.

Is this the expected result? If so, how can I store app data so my clients can recover it besides implementing my own server?

XAML control 'does not exist in the current context'

I'm getting an intermittent error where my XAML codebehind complains that a control 'does not exist in the current context'.

This is my .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"
             x:Class="MyApp_Mobile.IncidentReport"
             Title="Report Incidents">
  <StackLayout Spacing="5" x:Name="layoutIncident">
    <Label Text="Incident Type:" VerticalOptions="Center" HorizontalOptions="StartAndExpand" />
    <Picker x:Name="IncidentTypePicker1" Title="Incident Type" HorizontalOptions="FillAndExpand">
      <Picker.Items>
        <x:String>Theft</x:String>
        <x:String>Fire</x:String>
        <x:String>Accident</x:String>
      </Picker.Items>
    </Picker>
    <Label Text="Incident Description:" VerticalOptions="Center" HorizontalOptions="StartAndExpand" />
    <Editor x:Name="IncidentDescription" WidthRequest="400" HeightRequest="200" />
    <Button Text="Submit" Clicked="OnButtonClicked" />
    <Label x:Name="lblMessage" Text="" VerticalOptions="Center" HorizontalOptions="StartAndExpand" />
  </StackLayout>
</ContentPage>

And this is my .xaml.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;

namespace MyApp_Mobile
{
    public partial class IncidentReport : ContentPage
    {
        int count = 0;

        public IncidentReport()
        {
            InitializeComponent();
        }

        public void OnButtonClicked(object sender, EventArgs args)
        {
            lblMessage.Text = IncidentTypePicker1.SelectedIndex.ToString() + " " + IncidentDescription.Text;

            count++;
            ((Button)sender).Text =
                String.Format("{0} click{1}!", count, count == 1 ? "" : "s");
        }
    }
}

The IDE (Visual Studio 2013) sometimes complains that IncidentTypePicker1 and IncidentDescription do not exist, and sometimes it does not complain and I am able to Build and Deploy the app. Is there any reason for this intermittent error?


Xamarin.Forms send name of xaml to Xamarin.Android to use in Google Analytics

Hello , my name is Pedro ..

I need of help ,

Problem:
I need use GoogleAnalytics in my app , and I'm using with .JAR , in android to initialize GoogleAnalytics need an Activity in parameter, but I'm using Xamarin.Forms , So I'm using XAML not Activity , How get XAML and parse to Activity?

Thank you very much in advance..


Pedro Carrijo

Get value on another page from first page using binding.

Lets say I passed one value to feedbackPage like this-

this.Navigation.PushAsync (new FeedbackPage(SelectedItem));

and I am accessing it on feedbackPage like-

        String Get_item="";
        public FeedbackPage (String SelectedItem)
                {
                    InitializeComponent ();

                    Get_item=SelectedItem;

                }

Now I want to display Get_item on my page using Label binding so I am doing like-

<Label Text="{Binding Get_item}"/>

So its giving error- Property content is null or is not IEnumerable.
How make this possible?

Problem layout is reduce with shared connection bar

I have a little problem, when i share my internet connection, the RelativeLayout is reduce with 2 blank bar on left and right side Image may be NSFW.
Clik here to view.
:(

Many thanks,

Paulin.

Invalid number of rows in section

I trying to bind a ListView with an ObservableCollection. It works on both Windows Phone and Android but when running it on iOS I get an exception. The message says:

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (130) must be equal to the number of rows contained in that section before the update (0), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).

 public partial class TransfersView : ContentPage
     {
         public TransfersView(TransfersViewModel model)
         {
             InitializeComponent();

             BindingContext = model;  
         }
     }


  <ListView x:Name="Transfers" ItemsSource="{Binding Transfers}">
     <ListView.ItemTemplate>
       <DataTemplate>
         <TextCell Text="{Binding Player}" />
       </DataTemplate>
     </ListView.ItemTemplate>
   </ListView>

Does anyone has a solution?

How to transfer cookie inside Url in UrlImageSource ?

Hi Everyone,
I have some problem about getting image resources from server. Would you like to help me ?
I have an url like this : https://[host]/Member/abcxyz.png
But i don't allow client get anything without login. Request from client have to include my cookie.

I don't know how to send cookie into UrlImageSource of Image control.
I have these question :
- How to transfer cookie into Url inside UrlImageSource ?
- When UrlImageSource get image from Url, how to set cookie to all request ?

Android not persisting App.Current.Properties

Hi,

I'm currently stuck with a bug using App.Current.Properties.
I have an application deployed to iOs and Android. I have a common project containing View, Viewmodels...
Into my first screen, I have a login/password form. When the user logs in, I save its values into App.Current.Properties and then call SavePropertiesAsync.
The user do what he has to do and then quits the application.
Later, he comes back to the app and then, i load values into the different textboxes.

This works well on iOs app but not in Android one. Saving and Loading values is done by the same class (shared into a portable class library) and these calls are done into the same ViewModel for both app so the code is exactly the same in iOs and Android apps.

Another detail that is important : it works on Android when debugging. It doesn't work when I create the apk package, sign it and then install it manually.

Environment :
- Developping with Visual Studio 2015 Enterprise Update 2
- Xamarin versions for the Android app :
- Xamarin.Forms 2.2.0.31
- Xamarin.Android.* : 23.3.0
- Xamarin version for the portable class library that owns Views and viewmodels : Xamarin.Forms 2.2.0.31

Steps to NOT reproduce the bug :
All these steps must be done in debug mode
- Open the application
- fill login/password fields and validate the connection
- (here, the connection is verified and the values are saved into app.current.properties)
- quit the application
- restart the application
- All the fields are filled

Steps to reproduce the bug :
Do the same steps but not in debug mode (just create apk, sign it, install it manually).

Do you know why I got this bug ?

Fullscreen, "top most" overlays

Can XF expose a built in mechanism for adding custom views that is overlayed on top of any other UI elements with a fixed position and size?
For example in iOS, UIApplication.SharedApplication.KeyWindow will be exposed as Screen.Children.Add(new BoxView).


ScrollView inside StackLayout not visible.

I am using following code. I am executing the app in windows phone 8. In output screen I can see only titleLable(Label) and nextButton (Button). ScrollView is not visible nor any component inside it.

ContentPage.Content = new StackLayout
{
    Children = 
        {
            titleLabel,
            new ScrollView
            {
                Content = new StackLayout
                {                            
                    Children =
                    {
                        someEntry,
                        someEditor,
                        someLabel
                    },
                }
            },
             nextButton
        }
};

ListView linewrap

how to set the automatic transfer(to next line) of long lines, sometimes item does not fit into the screen?

Option to run xamarin app on iOS Simulator is disable

Hi,
I tried to run app on Xamarin studio for iOS simulator but the there is no list for iOS simulator available.Pls refer attach .
It was running well for my previous projects but this time I got this error.

Changing main/root page: Problems with android

Hi
I am building an application where i need to remove the initial page from the navigation stack. When started the user is presented with a login screen which I want to have removed from the stack after the user have been successfully logged in. I have tried several approaches:
- Setting a new MainPage
- Removing the page from the stack using navigationPage.Navigation.Removepage(page p)

Both of these work ok on ios but not on android. Whenever i rotate the phone or switches out of the app and back in again the loginpage will always be shown.

I cannot figure out if this is a bug or if I am doing something wrong here. Do any of you know an approach to working around this problem? It literally makes me crazy!

Thank you very much in advance and have a great day.

Customized Popup Page in Xamarin Forms

Hi ,

We need to implement the Popup screen with user inputs (Entry,Picker, Date Picker, Time Picker) controls.

In Existing Xamarin Android application , we used "AlertDialog.Builder" to use customized Layout.

Kindly suggest on how to acheive the same with Xamarin.Forms?

Viewing all 81910 articles
Browse latest View live


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