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

How to save audio file after recording voice in Xamarin.Forms

$
0
0

I am wondering how to save an audio file in Xamarin forms. I can get the location where to save to AppDataDirectory using Xamarin.Essentials:

var mainDir = FileSystem.AppDataDirectory;

But I am not sure how to save it in code, right after recording it using the NateRickard AudioRecorder Plugin:

var recordTask = await recorder.StartRecording();
var audioFile = await recordTastk;

Its same as saving/creating any binary file in C#? Say its same as saving an image file? And additionally do I need to use Dependency Injection to save it using platform specific code, or I can manage to only do it from the PCL code?


Debug connection lost on breakpoints

$
0
0

Hello,

not sure if it's just me, if it's android, or what else, but when I am debugging (android in this case), i only have a limited number of seconds (seems to be under 30) where I can actually debug in Visual Studio 2017 on Windows 10.

If i set a breakpoint and don't hit Continue within 20-30 sec my connection gets lost and i have to restart the app again.

I can't even explain how annoying it is as most times that I want to analyze an object, or a loop etc takes more more than that.

Does it happen to anybody else? Is there a solution?

Thanks!

Exception Thrown on line UIApplication.SharedApplication.Delegate.GetWindow().SafeAreaInsets.Bottom

$
0
0

Can anyone help me understand why I'm getting an exception error when I hit the line UIApplication.SharedApplication.Delegate.GetWindow().SafeAreaInsets.Bottom? Thanks for the help in advance

This code is located in the iOS project of a Xamarin Form Solution. I call this methods through an interface in the shared project when the screen is loading.

public ImageSource GetDisclaimerImageSource()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
{
if (UIApplication.SharedApplication.Delegate.GetWindow().SafeAreaInsets.Bottom > 0.0)
{
var iphoneX = UIImage.FromBundle("iphoneXBG");
var iphoneXStream = iphoneX.AsPNG().AsStream();
return Xamarin.Forms.ImageSource.FromStream(() => { return iphoneXStream; });
}
}
var iphone8 = UIImage.FromBundle("iPhone8BG");
var iphone8Stream = iphone8.AsPNG().AsStream();
return Xamarin.Forms.ImageSource.FromStream(() => { return iphone8Stream; });
}
}
}

how to set margin properly inside CollectionView

$
0
0

@Colex I have successfully implemented the CollectionView in my project it renders my image, frame and text however when I tried to add another image the new frame is close in the first frame how can I make a gap in between two frame inside CollectionView I have tried setting margins and padding in frame here is my code and screenshots

<CollectionView ItemsSource="{Binding PopularActivities}" ItemsLayout="{x:Static ListItemsLayout.HorizontalList}" HeightRequest="300" Margin="10,0,0,0">
                        <CollectionView.ItemTemplate>
                            <DataTemplate>
                                <Frame Padding="0" Margin="10,0,50,5" CornerRadius="4" WidthRequest="290">
                                    <StackLayout WidthRequest="150">
                                        <Image Source="{Binding ImageSrc}" HeightRequest="200" Aspect="AspectFill"/>
                                        <Label Margin="5,0,0,0" Text="{Binding Name}"  HorizontalTextAlignment="Start" VerticalTextAlignment="Start"  HeightRequest="20" WidthRequest="50"/>
                                        <StackLayout Orientation="Horizontal" Margin="5,0,0,0">
                                            <Label FontSize="Micro" Text="{Binding reviews}"/>
                                            <Label FontSize="Micro" Text="|"/>
                                            <Label FontSize="Micro" Text="{Binding booked} "/>
                                            <Label FontSize="Micro" Text="Booked"/>
                                        </StackLayout>
                                        <StackLayout HeightRequest="70">
                                            <StackLayout Orientation="Horizontal" Margin="5,40,0,0">
                                                <Label FontAttributes="Bold" Text="{Binding price}" HorizontalOptions="Start"/>
                                                <Label Text="Available Today" HorizontalOptions="End" TextColor="ForestGreen" FontSize="Micro" Margin="150,0,0,0"/>
                                            </StackLayout>
                                        </StackLayout>
                                    </StackLayout>
                                </Frame>
                            </DataTemplate>
                        </CollectionView.ItemTemplate>
                    </CollectionView>

and here is the screenshot

Will Xamarin consider supporting ScrollView that scroll in both directions?

$
0
0

ScrollView in Xamarin.Forms does not scroll in both directions.

I could see that, iOS has a UIScrollView which can scroll in both horizontal and vertical directions and similarly the WindowsPhone and WinRT platforms. Expect Android which alone don't have support for scrollView in both directions, Can Xamarin make some changes in the Android ScrollView Renderer and provide support for a ScrollView that could scroll in both Horizontal and vertical directions.

It would me much helpful for developers of Xamarin to have a ScrollView that scrolls in both direction which would reduce a lot of tweeks and hacks in our side. Can Xamarin consider this?

How To Show A Loading Screen (Cross Platform)

$
0
0

Hi everyone! I want to show a loading overlay screen on my app till my function gets completed. I want to solve this in a cross platform way. Not with iOS specific or Android specific code. Thanks!

UWP MenuItem

$
0
0

Is there a way that I can get a menu item to show up in the navigation panel like android for UWP. This is what I have so far.

<ViewCell>
    <ViewCell.ContextActions>
        <MenuItem Command="{Binding FolderDetailCommand}"
            CommandParameter="{Binding .}"
            Text="More" />
                 <MenuItem Command="{Binding DeleteCommand}"
            CommandParameter="{Binding .}"
            IsDestructive="True"
            Text="Delete" />
    </ViewCell.ContextActions>
    <StackLayout Padding="10"
            Orientation="Horizontal">
        <Label FontFamily="{StaticResource FontAwesomeRegular}"
            FontSize="Large"
            Text="{x:Static core:FontAwesomeRegularIcons.FolderOpen}"
            TextColor="{Binding Color}" />
        <Label FontAttributes="Bold"
            Margin="10,0"
            LineBreakMode="NoWrap"
            Text="{Binding Name}" />
    </StackLayout>
</ViewCell>

How to get DeviceId in android and ios


PIcker and sqlite commands

$
0
0

I have a general question which i would like to ask, but basically i have a table with counters and the id of the products, the counters represent how often the product has been bought, but when i execute the sqlite command for the picker, i get the information duplicated the more times that i click, the more the items get duplicated, is there a way to avoid it? As i want to have the information displayed only one time. For example, i have added 2 items with their id and counters, in the picker i just want to display that data everytime that i click on the picker without it adding the same data twice again.

How to read SIP interface in Xamarin Forms

$
0
0

Hi All,
I have a requirement in my project in which i have to read data through SPI interface and convert it into meaningful data. SPI interface will provide the elevator information.
Need help how to read data in Xamarin forms and parse it in meaning full data.

Hello! When clicking an text-entry-box i get null reference exception object reference not set to an

$
0
0

"Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object."

This is my xaml code from the page in which the text-entry-box is in. The exception is thrown when I click on the entry box, before I am able to type anything in it.
----xaml, the page with the entry box--------

<ContentPage.BindingContext>

</ContentPage.BindingContext>

<ContentPage.Content>
    <StackLayout HorizontalOptions="Center" VerticalOptions="Center" Spacing="10">

        <Entry Text="{Binding Keyword}"  MaxLength="15"/>

        <Button Text="Send" BorderColor="Black" TextColor="White"   FontAttributes="Bold" FontSize="20" BackgroundColor="#f49131" 
    Command="{Binding CheckCommand}" x:Name="send" IsVisible="true" CornerRadius="10"/>

</StackLayout>

</ContentPage.Content>

And this is the code from the viewmodel, which is the bindingcontext to the former page ^^

public string Keyword { get; set; }  <----- this is what the entry box's text is binded to.
    public int ID { get; set; }

    public ICommand CheckCommand
    {
        get
        {
            return new Command(async () =>
            {


                Checks = await _apiServices.GetCheckAsync(Keyword);
                if (_checks.Count > 0)
                {                         
                        Settings.Chk = "true";                          

                        await Application.Current.MainPage.DisplayAlert("message", "message.", "ok");                        
                 } 
                    else
                    {
                        await Application.Current.MainPage.DisplayAlert("Feil kode", "Det oppstod en feil.", "ok");
                    }
                }        
            });
        }

}

xmlns:d="http://xamarin.com/schemas/2014/forms/design"

$
0
0

i recently saw this new namespace in a new Contentpage i added to my project. What is it about?

Is it possible to show Context Actions on Tap/ShortPress

$
0
0

Hi,

Do you know if there is possibility to show Context Actions on click and also select item?
Now Context Actions show up on long press and I can select item on click.

XAML Custom Namespace Schemas in Xamarin.Forms are not reachable in visual studio for mac

$
0
0

I want to have access to some tags I created and use them but I cannot find them in visual studio for mac. Is there any extensions or sth which help me to have access to custom tags?

How to call the method available in Android and iOS project from Xamarin Forms project?

$
0
0

I do have a button in my Xamarin Forms Page. Whenever the button is clicked, I need to call the method in Android Project (in MainActivity.cs) if the device is Android and call the method in iOS Project (in AppDelegate.cs) if the device is iPhone.

Can someone help me how can I do this?

A method in Xamarin Forms

private async void BtnStart_Clicked(object sender, EventArgs e)
{
    //if Android call StartBeepWork in MainActivity.cs else call StartBeepWork in AppDelegate.cs
}

The method in MainActivity.cs and AppDelegate.cs

public void StartBeepWork()
{
    //process
}

Add IsActive Binding parameter in Behavior

$
0
0

Hello,

I have a Behavior to Valid the not null property of a Picker and I want to add a Bindable property named IsActive to specify if the validator is active or not.

But, my binded value not changed the BindingProperty IsActive. Can you help me please ?

Thanks

How to navigate from a UIViewController to a Forms ContentPage (with PageRenderer) in IOS

$
0
0

Hi,

I need to navigate from a UIViewControllerPage to a Content page (with custom PageRenderer). I found this - https://github.com/xamarin/xamarin-forms-samples/tree/master/Native2Forms and it is working fine if the Content page does not use custom PageRenderer. But for my case, I have a ContentPage which is using custom PageRenderer. And I need to navigate this Content page from my UIViewController (another PageRenderer for iOS).

How can I solve this?

Thank you,
Arefin

DatePicker Change Calendar Type

$
0
0

Is it possible to change the date picker default Gregorian calendar to another calendar type?

Classes suddenly passed by reference and binding issues

$
0
0

I'm working on my first Xamarin project, using Xamarin.Forms with MVVM structure.
I'm not using Prism or the like but I am using UnityContainer and I'm initially targeting Android.
My App takes in a number of quickly sequenced events triggered by Bluetooth Characteristic Notifications. Data updated in this way is then displayed on a screen in a ListView.
All was working well, but in the last couple of days class instances passed to functions have suddenly started to be passed by reference (so changes made to them for local use within the function now effect their original instance i.e. in the ListView source) and at the same time I'm getting odd binding issues whereby if a number of class instances are updated in quick succession the values of the last instance updated overwrites the others.

The passing by reference for class instances I've circumvented by creating a new instance of the class locally and copying property values over, which is what I expect to happen automatically, but this isn't ideal.

Has anyone seen this before and more importantly any ideas on the cause?

Any help would be much appreciated.

How to add line breaks in a label in Xamarin Forms using XAML

$
0
0

I am trying to add line breaks to a label in Xamarin Forms using XAML, but it doesn't seem to work. This is the code I have right now that doesn't work:

<Label Text="All my text goes here etc\r\nawljfal alwef law fawlef lwemfalwfem" TextColor="White" WidthRequest="100" />

The '\r\n' actually outputs in the label text.

Viewing all 77050 articles
Browse latest View live


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