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

How to detect if the device "notch", the model or the height of the screen (from shared code)?

$
0
0

I want to put a margin / padding top if the device is iOS and has notch.
And I want to do it from the generic code not using the specific iOS project.

I've been looking for a lot and I think I can not check if it has notch and not know if it's an iPhone X, so...
- I can not know the model of the device
- I can not know if the device has notch
- Can I know the height and orientation of the device?

If possible I could do the following:
if (
(Device.RuntimePlatform == Device.iOS) // Ok
&& (check orientation == portrait)
&& (check height device == XXXX)
){
Padding = new Thickness(0, 20, 0, 0);
}


XAML Learning Curve

$
0
0

Hi everyone,

Most of the time, I am developing apps using Xamarin.iOS and I am comfortable with it. But this time, I got one more job that requires the same app for Android version. Since I have no knowledge of XAML, I thought that it is better to start with Xamarin.iOS and then developing the app with Xamarin.Android.

I need to develop the app in 3 months for both iOS and Android version.

What are your experience for learning XAML? Do you think it is better to focus on Xamarin.Forms rather than Xamarin.Native? or should I stick with what I am comfortable with because of time limitation?

Thank you very much!

NFC Reader for iOS11 App

$
0
0

Hello,

Now that Apple has exposed the NFC APIs for the app development and we can create iOS 11 apps to read/write NFC tags, we wanted to create an iOS App (using Xamarin forms or native iOS using .net) for the same. So just wanted to know if there are any updates to Xamarin Forms that would allow us to create the app.

Source Reference for binding in a standalone resource dictionary to the a content page context

$
0
0

What should the binding source reference for be in a Xamarin forms 3 standalone resource dictionary? Given the following XAML:

<DataTemplate x:Key="newAddressTemplate">
    <ViewCell>
        <ViewCell.View>
            <Label TextColor="{Binding LabelColorName}" Text="{Binding Label}" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
                <Label.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding Path=BindingContext.NewAddressCommand, Source={x:Reference Page}}" CommandParameter="{Binding AddressDestinationType}" />
                </Label.GestureRecognizers>
            </Label>
        </ViewCell.View>
    </ViewCell>
</DataTemplate>

The TapGestureRecognizer Command binding works if the resource dictionary is in the content page itself (where the content page includes x:Name="Page"), but not when it is moved to a standalone file containing only the resource dictionary. Adding x:Name="Page" to the resource dictionary tag doesn't resolve the issue. It seems like the reference should be to parent whatever that might be.

How to add checkbox in xamarin.forms?

$
0
0

I am wondering how to do that with full functionalities.
I have created that thanks to this answer but I couldn't handle the check/uncheck events so how to handle that?

XamarinForms APK won't install

$
0
0

We have two apps which are deployed using HockeyApp (Ad Hoc deployment).
After recent updates on my Mac (iOS & Visual Studio Community) I can't install them on Android devices (deployment to iOS devices steill works fine).

I have a message "App not installed".
It is the same when I try to install from APK file on the device (signed or unsigned apk).
I can install the app on the phone in Release mode when I have it connected to the Mac.

I'm not sure what else I should check to investigate this issue?

Visual Studio Community version 7.6.1 (build 9)
iOS version 10.13.16
HockeyApp.SDK.Xamarin 5.1.2
Xamarin.Forms 3.1.0.697729

Add a reference to assembly

$
0
0

Hi to all,

I want to add Xlabs to my project, so I read how to implement it ( https://github.com/XLabs/Xamarin-Forms-Labs/wiki ).

I found this problem:

when I try to add this code to "App.cs" in my WinPhone 8.1 project

var app = new XFormsAppWP();
app.Init(this);

on "Init" (app.Init(this)) I had this problem:

The type 'Application' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
'

I have a "Quick Fix" option -> Add a reference to assembly 'System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e', but when I try to click on it, nothing happens.

In "Reference Manager" (WinPhone project -> Right click -> Add reference) I can't add this reference because I can't found it.

I using Visual Studio 2015 pro, Xamarin.Forms PCL.
My project targeting .NET 4.5 (I tried also with 4.5.2 but I had the same problem).

How can I resolve this problem?

Navigation via popasync after saving data

$
0
0

I am using MVVM view model to save data. A view model command gets invoked when the user saves the data after clicking on the Toolbaritem button "Save". After saving the data I want to return to the previous page. I could always invoke popasync in the clicked event from the code behind however, that would require the saving to be done in the code behind instead of the view model which is a bad practice as the view should not be aware of any data related aspects. On the other hand I don't want to invoke popasync in view model as it will mean the view model should have knowledge of the views and navigation which is again a bad practice? Whats the best design pattern to achieve this? Is it possible to invoke both the command and clicked event on the same button?


Is it possible to attach an effect in XAML on only one device platform?

$
0
0

I implemented a Entry effect which only needs to be applied on iOS. Right now, I'm attaching it in code-behind by making sure the current platform is iOS. Is it possible to do this easily in XAML instead (i.e. do not attach it on other platforms)?

The name 'InitializeComponent' does not exist in the current context

$
0
0

This is really strange and inconsistent. Sometimes it runs fine and sometimes I get the following error

'The name 'InitializeComponent' does not exist in the current context'

There is absolutely no change in code and project settings. Just sometimes it runs and sometimes it throws this compilation error. How to resolve this?

How to get absolute path of a file stored in application?

$
0
0

Hello,

I am working on Xamarin.Forms application.

I have a folder named "ProjectsDoc" in my PCL project. There are two files in it - File1.pdf and File2.doc.

Now I need to get the path of these files and open them in the default app installed in user's phone when user click on specific button. I have checked over different posts/articles but could not find how to do so. Can you please help me how can I get the path of these files?

Thanks

Binding Two Properties from a list in XAML

$
0
0

I have a list that I am getting from a Database with TimeStarted and TimeEnded. I would like to combine them both into a Timespan for a listView. How can I make a new property in my ViewModel that combines those two properties (or maybe do it directly in XAML with a value converter)?

How to add padding to SearchBar inside Horizontal StackLayout?

$
0
0

For some purpose I want to position SearchBar inside StackLayout whose Orientation is Horizontal and add padding to that StackLayout but I found that the SearchBar takes all the Width space as shown in second SearchBar while when the Orientation is Vertical it works normally as shown in first SearchBar the below image:

Here is the code for both StackLayouts:

    <StackLayout Orientation="Vertical" Padding="100,0,100,0">
        <SearchBar/>
    </StackLayout>

    <StackLayout Orientation="Horizontal" Padding="100,0,100,0">
        <SearchBar/>
    </StackLayout>

I also tried to put the Horizontal-Orientated StackLayout into a Vertcal-Orientated StackLayout as shown in code below:

        <StackLayout Orientation="Vertical" Padding="100,0,100,0">
            <StackLayout Orientation="Horizontal">
                <SearchBar/>
            </StackLayout>
        </StackLayout>

But it does not help too, So how to solve that problem?

How keep recent Entry value when go next page.

$
0
0

Hi, i want to keep entry value which i type in entry box then i go another page and then went back to the main page where previously i type somethings in entry box. Now how i keep those data without save in local database.

Binding to an element of an array (or List)

$
0
0

After much googling, I haven't found an answer to this.

I have an array of colors. I want to bind a Button's BorderColor to a specific element within an array.
What is the syntax to achieve this?

Xaml:

 BorderColor="{Binding ButtonColors[11], Converter={Services:ByteToBorderColourConverter}}"

ViewModel:

private List<byte> buttoncolors;

public List<Byte> ButtonColors
    {
        get => buttoncolors;
        set
        {
            buttoncolors = value;
            OnPropertyChanged();
        }
    }

...

ButtonColors[11] = (Byte)Data[3];

I've also tried implementing this with List, but it also doesn't work.
I think the xaml binding syntax is incorrect maybe?


Upgarding to xamarin forms nightly version causes null reference exception

$
0
0

We have created a custom control and used customrender for converting it forms to native. We faced null reference exception only when using the 3.5.0.979221-nightly version and it works fine when using 3.3.0.912540. On further analysis we found that the null reference exception occurs in all Xamarin forms nightly version. Can any one please explain the difference between the Xamarin forms nightly version and normal xamarin forms version. We don't know what the reason for this. Could anyone please help to resolve the issue. The sample code is given below

public static IVisualElementRenderer Convert(Xamarin.Forms.View source, Xamarin.Forms.VisualElement valid)
{
IVisualElementRenderer render = (IVisualElementRenderer)source.GetValue(RendererProperty);
if (render == null)
{
render = Platform.CreateRenderer(source);
source.SetValue(RendererProperty, render);
var p = PlatformProperty.GetValue(valid);
PlatformProperty.SetValue(source, p);
IsPlatformEnabledProperty.SetValue(source, true);
}

        return render;
    }

I have also attached the image showing the issue.

Frame CornerRadius for each side

$
0
0

Hi,
Xamarin froms frame need to set custom radius. For Left side different number and right side different radius, Is it possible to do like this?

Thanks in advance.

Round Stacklayout OneSide(Left Top and Left Bottom)

$
0
0

Hello Delveloperd,

I want to implement only one side round stacklayout (Left Top and Left Bottom).
It's posible in xamarin forms and blow i upload a image for example like this.

any guid for this

Thanks

Deepak

Cross Platform Camera Frame Analysis

$
0
0

Is there a way I can access ios/Android camera frames to do real-time frame analysis?

Is there a Recipie to implemnt a custom NavigationPageRenderer for the UWP Platform

$
0
0

Hello,

I am trying to add a AppBar to a Xamarin Forms Application targeting the UWP platform. From what I understand UWP has a top an bottom app bar definde on the page and therefore I would like to access it. As it is not possible to do it directly I think I need a custom renderer for the NavigationPage - the same thing was also necessary for the project's iOS page.

When I tried to follow the reciepie that I have used in the iOS and Andoid application to modify the layout of the NavigationPage I found that this is not possible as most of the methods are private or not overridable in the UWP NaviationPageRenderer.

So is there a some guidance how to modify the NavigationPage of an UWP application or is this the wrong approach all together? I spent extensive time on the internet and so far have not found any solution.

A sample putting me in the right direction would be much appreciated.

TIA

Viewing all 91519 articles
Browse latest View live


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