Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

Native Printing with Android


Xamarin Binding to complex bool

$
0
0

Hello,

I want to bind an IsVisible property to a bool with a complex getter.
How am I supposed to notify the view if this getter should be called again?

Pseudo Code:

List<int> ListOfNumbers;
public bool HasUnevenElements
        {
            get { return ListOfNumbers.Any(x => x == IsUneven(x)); }
        }

private bool Uneven(int number){
//returns true/false wheter number is uneven or not
}

How to implement the INPC here?

Here I want to bind for example like this:

<Label Text="This list has uneven elements" IsVisible="{Binding HasUnevenElements}" />

How to correctly import Facebook SDK for Xamarin forms

$
0
0

Hello,
I'm currently making a Xamarin Forms app that needs to authenticate users, using Facebook for Android.
However, I'm having a hard time figuring out the steps to use the Facebook-SDK in my project.

My question is: Where do I import the following code to my Xamarin forms project ?

Import the Facebook SDK

Important: If you're adding the SDK to an existing project, start at step 3.

  1. Go to Android Studio | New Project | Minimum SDK.
  2. Select API 15: Android 4.0.3 (IceCreamSandwich) or higher and create your new project.
  3. In your project, open** your_app | Gradle Scripts | build.gradle (Project)** and add the following repository to the buildscript { repositories {}} section to >download the SDK from the Maven Central Repository:
  • mavenCentral()
  1. In your project, open** your_app | Gradle Scripts | build.gradle (Module: app)** and add the following compile statement to the dependencies{} section to >compile the latest version of the SDK:
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'

  2. Build your project.

  3. Add the following statements to import the Facebook SDK packages:
  • import com.facebook.FacebookSdk;
  • import com.facebook.appevents.AppEventsLogger;

I've already added the Facebook SDK using gradle extention to Visual studio. However I, cant figure out point 6

Thanks!

Missing recommended icon file when packing iOS project

$
0
0

When I tried to packing my iOS project from Xamarin forms project I face this issue

ERROR ITMS-90022: "Missing required icon file. The bundle does not contain an app icon for iPhone / iPod Touch of exactly '120x120' pixels, in .png format for iOS versions >= 7.0."

ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '76x76' pixels, in .png format for iOS versions >= 7.0."

ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '167x167' pixels, in .png format for iOS versions supporting iPad Pro."

ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '152x152' pixels, in .png format for iOS versions >= 7.0."

my Content.json

{
"images": [
{
"filename": "Icon.png",
"size": "57x57",
"scale": "1x",
"idiom": "iphone"
},

{
  "filename": "Icon@2x.png",
  "size": "144x144",
  "scale": "2x",
  "idiom": "iphone"
},

{
  "filename": "Icon-App-40x40@1x.png",
  "size": "20x20",
  "scale": "2x",
  "idiom": "iphone"
},
{
  "filename": "Icon-App-60x60@1x.png",
  "size": "20x20",
  "scale": "3x",
  "idiom": "iphone"
},
{
  "filename": "Icon-App-29x29@2x.png",
  "size": "29x29",
  "scale": "2x",
  "idiom": "iphone"
},
{
  "filename": "Icon-App-29x29@3x.png",
  "size": "29x29",
  "scale": "3x",
  "idiom": "iphone"
},
{
  "filename": "Icon-App-40x40@2x.png",
  "size": "40x40",
  "scale": "2x",
  "idiom": "iphone"
},
{
  "filename": "Icon-App-40x40@3x.png",
  "size": "40x40",
  "scale": "3x",
  "idiom": "iphone"
},
{
  "filename": "Icon-App-60x60@2x.png",
  "size": "60x60",
  "scale": "2x",
  "idiom": "iphone"
},
{
  "filename": "Icon-App-60x60@3x.png",
  "size": "60x60",
  "scale": "3x",
  "idiom": "iphone"
},
{
  "filename": "Icon-App-20x20@1x.png",
  "size": "20x20",
  "scale": "1x",
  "idiom": "ipad"
},
{
  "filename": "Icon-App-20x20@2x.png",
  "size": "20x20",
  "scale": "2x",
  "idiom": "ipad"
},
{
  "filename": "Icon-App-29x29@1x.png",
  "size": "29x29",
  "scale": "1x",
  "idiom": "ipad"
},
{
  "filename": "Icon-App-29x29@2x.png",
  "size": "29x29",
  "scale": "2x",
  "idiom": "ipad"
},
{
  "filename": "Icon-App-40x40@1x.png",
  "size": "40x40",
  "scale": "1x",
  "idiom": "ipad"
},
{
  "filename": "Icon-App-40x40@2x.png",
  "size": "40x40",
  "scale": "2x",
  "idiom": "ipad"
},
{
  "filename": "Icon-App-83.5x83.5@2x.png",
  "size": "83.5x83.5",
  "scale": "2x",
  "idiom": "ipad"
},
{
  "filename": "Icon-App-76x76@1x.png",
  "size": "76x76",
  "scale": "1x",
  "idiom": "ipad"
},
{
  "filename": "Icon-App-76x76@2x.png",
  "size": "76x76",
  "scale": "2x",
  "idiom": "ipad"
},
{
  "size": "1024x1024",
  "scale": "1x",
  "idiom": "ios-marketing"
},
{
  "role": "notificationCenter",
  "size": "24x24",
  "subtype": "38mm",
  "scale": "2x",
  "idiom": "watch"
},
{
  "role": "notificationCenter",
  "size": "27.5x27.5",
  "subtype": "42mm",
  "scale": "2x",
  "idiom": "watch"
},
{
  "role": "companionSettings",
  "size": "29x29",
  "scale": "2x",
  "idiom": "watch"
},
{
  "role": "companionSettings",
  "size": "29x29",
  "scale": "3x",
  "idiom": "watch"
},
{
  "role": "appLauncher",
  "size": "40x40",
  "subtype": "38mm",
  "scale": "2x",
  "idiom": "watch"
},
{
  "role": "longLook",
  "size": "44x44",
  "subtype": "42mm",
  "scale": "2x",
  "idiom": "watch"
},
{
  "role": "quickLook",
  "size": "86x86",
  "subtype": "38mm",
  "scale": "2x",
  "idiom": "watch"
},
{
  "role": "quickLook",
  "size": "98x98",
  "subtype": "42mm",
  "scale": "2x",
  "idiom": "watch"
},
{
  "size": "16x16",
  "scale": "1x",
  "idiom": "mac"
},
{
  "size": "16x16",
  "scale": "2x",
  "idiom": "mac"
},
{
  "size": "32x32",
  "scale": "1x",
  "idiom": "mac"
},
{
  "size": "32x32",
  "scale": "2x",
  "idiom": "mac"
},
{
  "size": "128x128",
  "scale": "1x",
  "idiom": "mac"
},
{
  "size": "128x128",
  "scale": "2x",
  "idiom": "mac"
},
{
  "size": "256x256",
  "scale": "1x",
  "idiom": "mac"
},
{
  "size": "256x256",
  "scale": "2x",
  "idiom": "mac"
},
{
  "size": "512x512",
  "scale": "1x",
  "idiom": "mac"
},
{
  "size": "512x512",
  "scale": "2x",
  "idiom": "mac"
}

],
"info": {
"version": 1,
"author": "xcode"
}
}

what I miss ??

Error running my first App on Visual Studio for Mac

$
0
0

Hi,

I have just started with Visual Studio for Mac

But when I try to run the iOS app I get

/Users/jassim/Projects/FirstXamarin/iOS/obj/iPhoneSimulator/Debug/device-builds/iphone9.1-10.3.1/actool/cloned-assets/Assets.xcassets: Warning: The app icon set "AppIcon" has an unassigned child. (FirstXamarin.iOS) actool

/Users/jassim/Projects/FirstXamarin/iOS/MTOUCH: Error MT0091: This version of Xamarin.iOS requires the iOS 11.0 SDK (shipped with Xcode 9). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs). (MT0091) (FirstXamarin.iOS)

I already downloaded xCode 9 but after downloading it shows 8.3.3 so I only left with the xCode 9.1 Beta

Do you recommend to download that or go for the second option mentioned in the Error? and how to go for the second option?

Thanks,
Jassim

Is it possible to use SKPaint.TextAlign in combination with SKCanvas.DrawTextOnPath

$
0
0

Hi,
right now i am using SKPaint.TextAlign in combination with SKCanvas.DrawText for text aligning, which works fine.
My goal was to replace DrawText with DrawTextOnPath but somehow it does not work to align text on the right side.
Is it a bug or does DrawTextOnPath works differently?
best regards
Fred

iOS11 - GetContainerUrl returning nil

$
0
0

NSFileManager.DefaultManager.GetContainerUrl(suiteName) is returning nil on the iOS11 simulators. This works fine on 10.X simulators.

Anybody know what is going on?

Xamarin Dropbox CoreApi not working after Dropbox switched off V1API support on 28.09.2017

$
0
0

Hi,
I was caught off guard on Friday when our application stopped working with Dropbox because I was using this component for a year and it worked flawlessly.

By looking around I found out that Dropbox deprecated V1 API support, Is there a chance to update this component to V2 API.

Thanks.


How to make following(please see the description) scenario generic

$
0
0

I came with some situation where I need to update only one property of class object(this is set using SetProperty method)

private ProfileSettings profileSettings;
public ProfileSettings ProfileSettings
{
get { return profileSettings; }
set { SetProperty(ref profileSettings, value); }//Used mvvmhelpers
}

here is my ProfileSettings class used for binding

public class ProfileSettings : BaseViewModel
{
   public string Country { get; set; }
  //some other properties like timezone,dateformat etc...
}

Now when I click on country label in my ProfileSettingsPage it takes me to listview where I select particular country from list provided and when I comeback(Ondisappearing) I am passing this country item back to ProfileSettingPage using messaging center with selectedItem as parameter(TArgs).

Problem
If I don't make the Country bindable inside ProfileSettings class like below,it's not updating my label on page.

private string country;
public string Country
{
  get { return country; }
  set { SetProperty(ref country, value); }
 }

It's same for all other properties in my ProfileSettings class.

Questions:
1. How to know exactly which property to update.(Note: I need to also update particular item.child property of listview)
2. Better,how to make this generic so that it works on any viewmodel property and view type(xamarin forms ->label,datepicker etc...)

I also need to post this changes using this same object without assigning each and every property manually(I feel that should be the handled on Binding level automatically).

Please help me how to approach this as much generic as possible.

Xamarin App that runs in the browser

$
0
0

I have a dilemma. I can develop an app in Xamarin that runs on mobile phones, but not on my Chromebook laptop!

Any advise? Why no support for Xamarin.Browser? Target would be server web pages that would display in any browser!

Thanks for your ideas on how to solve my dilemma.

Push notifications

$
0
0

Hi,

I have implemented IOS Push notifications using this plugin (https://github.com/CrossGeeks/PushNotificationPlugin). I will send silent push notifications and when I debug my app everything seems to work just fine. But when I disconnect my phone from the cable and I launch the app from my phone it does not work anymore. It looks like to the push message is not arrived. Any idea how this can be caused? Can it that I did not setup something correctly? How can I "debug" this without having the phone connected to the debugger? Can I log something to a file which I can copy later to the computer? Thanks for giving me some direction...

Xamarin Forms Customized Camera for iOS and Android, Custom Renderer?

$
0
0

I'm pretty new to Xamarin Forms and C# in general, and need som hints on the best way to create an app for iOS and Android. I want to use the Camera to take pictures / videos and later on send them through email or something, since I want customized controls on the camera, I'm guessing the stock camera won't be an option? Which gets us to Renderers, which is the best approach to this? Preferably in a MVVM way. I just want the camera and a few customized buttons on it.

Do I make on renderer for the different buttons objects and one for the camera, the buttons I'll do as extensions of the Button class, but what about the camera?

/Oliver

Device orientation change and CarouselView

$
0
0

Hi there!
I'm using the CarouselView along with Grial UI Kit in one of my Xamarin Forms App. I've got it work fine, in iOS & Android and it looks good in a portrait view on both the phones.

The issue arises in an iphone, when I change the orientation of the phone from portrait to landscape. The carousel view does not resize to fit the screen. I'm attaching some images that depict what happens:

From portrait to landscape:
image

From Landscape to portrait:
image

This does not happen on an android device, just on iphone.

If anyone has come across this and knows a solution, please do let me know.

Thanks
Noel

RelativeLayout code to XAML translation

$
0
0

Hi all,

I've got some sample c# code that I'm trying to translate into XAML because that's the standard we are using on our project. There's a piece of relativelayout code that I'm struggling to create a correct layout for. It's to get an image displayed in the middle of a contentpage:

       `relativeLayout.Children.Add(
            face,
            Constraint.RelativeToParent(parent => ((parent.Width / 2) - (face.Width / 2))),
            Constraint.RelativeToParent(parent => parent.Height * .25),
            Constraint.RelativeToParent(parent => parent.Width * .5),
            Constraint.RelativeToParent(parent => parent.Width * .5)
        );

        face.SizeChanged += (sender, e) => {
            relativeLayout.ForceLayout();
        };`

So far I've translated this to:

`<RelativeLayout HorizontalOptions="CenterAndExpand" HeightRequest="100">
    <Image Source="profile1.png"
                HorizontalOptions="Center"
                VerticalOptions="Center"
                RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5}"
                RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.25}"
                RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5}"
                RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5}">
    </Image>
</RelativeLayout>`

The bit that I'm unable to understand is how to base a constraint on the dimension on the parent and some other object simultaneously [ i.e. this expression ((parent.Width / 2) - (face.Width / 2))]

In XAML, there is only the RelativeToParent type of constraint.

thanks

NavigationPage.SetHasNavigationBar without animation?

$
0
0

Hello

I want to hide the NavigationBar without animation. Is that possible and if can you told me how?

How to hide the NavigationBar
NavigationPage.SetHasNavigationBar(this, false);


Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag

$
0
0

Hey all,

I am just working through the Hello MultiScreen tutorial on the docs, and I am receiving the following error:

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

I have tried the example source code posted with the tutorial and it also gives me this error, and a quick Google search turns up not much to do with Xamarin specifically, and it is mainly more from background services trying to launch activities. Has anyone come across this before?

Horizontal Stacklayout inside a ListView Cell

$
0
0

Hello everyone, i have a ListView defined in my View as follows:
`

<ListView.ItemTemplate>



                            </Entry>
                            <StackLayout    x:Name="ObjectChecks"
                        Orientation="Horizontal"
                                                AbsoluteLayout.LayoutBounds="1, 0.5, 0.85, 1"
                                                AbsoluteLayout.LayoutFlags="All">

                            </StackLayout>
                        </AbsoluteLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

`

I would like to add from the code behind a variable number of Switches to the ObjectChecks StackLayout and bind each of them to an element of a list in my ViewModel. This number is inserted at runtime by the user. Is there any way to do this? i don't seem to be able to access the StackLayout from code.

Thanks.

How to add a Label to a Relative layout and center it horizontally

$
0
0

Hi all,

I'm trying to horizontally center a label in a Relative Layout.

My intuitive way of doing it would be to add the label to the layout with an X constraint equal to the parent's width minus the label's width, all divided by two.

However, the parent's width can be had. The Label's width equals -1.

RelativeLayout relativeLayout = new RelativeLayout();

            Label CenteredLabel = new Label ();
            CenteredLabel.Text = "Center this";
            CenteredLabel.XAlign = TextAlignment.Center;
            CenteredLabel.MinimumWidthRequest = relativeLayout.Width;
            relativeLayout.Children.Add
                (CenteredLabel, Constraint.RelativeToParent ((parent)=>
                                                {return (parent.Width-CenteredLabel.Width)/2;}),
                  Constraint.Constant(0)
                );

Can anyone suggest why this is not working? Thanks!

Emergency: Can't install Microsoft.Bcl.Build.1.0.14 in Visual Studio 2015 for Android project

$
0
0

I am trying to use "PortableRest" for my Xamarin Forms portable projects(IOS project can add PortableRest.3.0.1 fine).
I can't add package "PortableRest.3.0.1" to my Droid project, the following are the error message in output.

I tried on both OS X and Window Xamarin Studio,
Xamarin Studio OS X/Windows doesn't have problem to add "PortableRest.3.0.1" to Android project at all.

I followed an old post said that I need to reinstall Portable library, Xamarin Studio,reboot etc, no matter what I do,
Visual Studio can't add "PortableRest.3.0.1",

Please help, I have been stuck here for few hours already.

Thank you!

=======Output=======
Resolved actions to install package 'PortableRest.3.0.1'
Install failed. Rolling back...
Package 'Microsoft.Bcl.Build.1.0.14 : ' does not exist in project 'App1.Droid'
Package 'Microsoft.Bcl.Build.1.0.14 : ' does not exist in folder 'C:\Users\Dev\Documents\Projects\App1\packages'
Could not install package 'Microsoft.Bcl.Build 1.0.14'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

=======Error=======
Error Could not install package 'Microsoft.Bcl.Build 1.0.14'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0

How do I create an options menu?

$
0
0

I'm afraid I couldn't find any information on this issue in the documentation, so I hope someone can help me with this obviously pretty easy task...

How do I create an options menu that pops up when clicking on the hardware button?

Thanks in advance,
jp99

Viewing all 204402 articles
Browse latest View live


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