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

UWP splashscreen not displaying in fullscreen

$
0
0

Dears,

My UWP splash screen is like below, It is not covering the entire screen.

Here is the screenshot of my uwp app Package.appxmanifest. Here I am selecting my splash screens.

I need a full-screen splash, please suggest a solution.
Thanks in advance :)


Newtonsoft JSON / Prism

$
0
0

So trying to do multiple HTTP requests and have a callback for each successful request.
My code looks like follows in the callback:
var locationResponse = JsonConvert.DeserializeObject(data, typeof(LocationResponse)); _eventAggregator.GetEvent<PlacesEvent>().Publish((LocationResponse) locationResponse);
The first callback response works fine and the eventAggregator works fine sending the data. But when the second callback is called the eventAggregator somehow fires the event before the data is serialized. I tried to run a Task.Delay(2000) between the deserialization and the eventAggregator callback which works fine.
I do not see what I am missing here?

Thanks in advance.

Aspect Ratio on ImageCropper

$
0
0

Hello!

How can i set a custom aspect ratio when using the Xam.Plugin.ImageCropper plugin?

in iOS i have the custom renderer where there are some options, i want to set aspect ration of "9 : 16" but this doesn't appear in the list:

               TOCropViewController picker = new TOCropViewController(image);

                picker.AspectRatioLockEnabled = true;
                picker.AspectRatioPickerButtonHidden = false;
                picker.AspectRatioPreset = TOCropViewControllerAspectRatioPreset.Square;

TOCropViewControllerAspectRatioPreset.TOCropViewControllerAspectRatioPreset16x9 exists but not 9x16.

There is an option for Custom, but I can't see how to fix that to 9x16.

Pushasync is not supported globally on android please use a navigation page.

$
0
0

Hi,
I have got the following code:

listView.ItemTapped += async (sender, e) =>{
       ARPage arPage = new ARPage(e.Item.ToString());
       await Navigation.PushAsync(arPage);
      ((ListView)sender).SelectedItem = null;
 };

After running I got the error:
Pushasync is not supported globally on android please use a navigation page.

Any idea that can help me out. Thanks

How to create a custom ButtonRenderer on Android that changes the button style?

$
0
0

Hey,

I have a custom button (which I called ColoredButton) which should be rendered with a different AppCompat Style on Android. So I created a custom renderer:

[assembly: ExportRenderer(typeof(ColoredButton), typeof(ColoredButtonRenderer))]
namespace MyApp.Droid.Controls
{
    class ColoredButtonRenderer : Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer
    {
        public ColoredButtonRenderer(Context context) : base(context)
        {
        }

        protected override AppCompatButton CreateNativeControl()
        {
            return new AppCompatButton(new ContextThemeWrapper(Context, Resource.Style.Widget_AppCompat_Button_Colored));
        }
    }
}

But it does not work. The buttons are shown with the standard style, not with Resource.Style.Widget_AppCompat_Button_Colored.

Anyone knows why?

Thanks!
Nathan

Entry field size in a grid

$
0
0

I am using a two column grid to layout my form. The columns are defined as 20% and 80%. I have an entry field in the 80% side, and am trying to control the width using the WidthRequest property. The entry fields does not respect this size attribute. It fills the cell in the grid. How can I make this work?

     <Entry Grid.Row="3" Grid.Column="1"  Style="{StaticResource EntryField}"  WidthRequest="300" Text="{Binding City}"/>

Trying to achieve:
Name Dave
Address 123 North st.
City LA

Urgent: MpMoviePlayerController not playing the video after latest Xamarin.IOS update

$
0
0

Hi All,
The following code in Xamarin IOS was working fine prior to the Xamarin IOS update to v2.0.50727

This is the code in a custom renderer in a Xamarin Forms app

     class WatchVideoRenderer : PageRenderer
    {
        MPMoviePlayerController moviePlayer;

        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            var url =  new NSUrl("http://192.168.12.4:8085/MediaUploads/1/211/520140731170618/DPM202.mp4");
            moviePlayer = new MPMoviePlayerController();
            moviePlayer.ContentUrl = url;
            moviePlayer.View.Frame = new CGRect((float)((NativeView.Bounds.Width - 600) / 2), (float)((NativeView.Bounds.Height - 450) / 2), 600, 400);

            MPMoviePlayerController.Notifications.ObserveLoadStateDidChange(OnLoadStateChanged);
            MPMoviePlayerController.Notifications.ObservePlaybackDidFinish(OnPlaybackComplete);

            View.AddSubview(moviePlayer.View);

            moviePlayer.PrepareToPlay();
            moviePlayer.ShouldAutoplay = true;
            moviePlayer.Play();
        }

        private void OnLoadStateChanged(object sender, NSNotificationEventArgs e)
        {
            if (moviePlayer.LoadState == MPMovieLoadState.Playable)
            {

            }
        }

        private void OnPlaybackComplete(object sender, MPMoviePlayerFinishedEventArgs e)
        {

        }
    }

As i said this was working till day before yesterday, after which I installed 2 updates on Xamarin.IOS & this is now failing. All i see is a black canvas & the video never loads.
No notifications from the MPMoviePlayerController are ever raised.
There is a release of this app scheduled for next week & this last minute bug is causing me headaches. Any help is really appreciated.

Thanks
Supreet

Looking for Signature Pad

$
0
0

Need to implement a signature pad into a xamarin forms app

I see there is Xamarin.Controls.SignaturePad.Forms but I cant find any sample on how to implement it in a PCL project

Any help would be appreciated

Mike


How does one create a Solution with multiple shared/portable projects inside?

$
0
0

So I have been trying to structure my app to be more like some of the "finished" sample projects. In particular I have heard that the Xamarin Evolve app has been created very well. SO I am trying to replicated it's structure as much as possible.
https://github.com/xamarinhq/app-evolve

But I can not figure out how to add multiple projects into my solution. I have tried a few things. FWI I am working with a PCL project. I started this project before the nixed that structure

  1. Right click, Add, New project, Xamarin forms. This created a .Net cross platform app, to do this I need to create at least one other project (Android/ios/windows) I do this then delete the mobile project. But this has problems and I dont think is the correct way of doing it.

  2. Right click, Add, Existing project. and from here I tried
    2A. I tried adding directly from XamarinEvolve. This messed everything up as the file names were all funky
    2B. I pulled the start to my PCL Project from my Source Control and tried modifying ti and sticking it it. I sort of got it working but the namespaces got all funky.

I just feel like there is a super simple way to do this, but my web searching as turned up diddly squat.

The type or namespace name 'ExamplePage' does not exist in the namespace 'Example'

$
0
0

Hello all,
I got a sample project online which is in Xamarin.Forms. I have changed the solution name, project name, and the namespaces. After building the Android project, I got the error:
Error CS0234: The type or namespace name 'ExamplePage' does not exist in the namespace 'Example' (are you missing an assembly reference?) (CS0234) (Example.Droid)

The change has been done everywhere except in the Resource.Designer.cs file, which is automatically generated. Please help me why I am getting this error although I have manually changed everything. Thanks

Drawing on photo and saving it

$
0
0

I'm using SkiaSharp to create canvas on which i can draw by touch, on another page i can make photo. I can send this photo as ImageSource to canvasPage and my question is:
Can i somehow make canvas displaying this photo so i can draw on it and then i save it to photo gallery (or even to memory of device), drawing on photo is my biggest problem here.

Animate StackLayout to left and right

$
0
0

Hi All,

I have created a stack layout with 3 children(stack layouts) as shown in the attached image file. I have to animate the main layout t left or right according to the button click.

If I click to right button, The middle part should move towards right and left part will be displayed with animation and vice versa.

How can I do that?

Please Help

Xamarin.Forms Maps UWP, IOS, details of phone and more

$
0
0

Okay, i'm doing my engineering degree project and i need to do few small Xamarin.Forms programs to compare them with Cordova and others.
1st i have few problems with Xamarin.Forms.Map which i used like in Xamarin.Forms.Map tutorial
1. On iOS version i have no "localization" button even if i have isShowingUser as true. Is this some bug or i do something wrong ?
2. I added some "basic" button and it's transparent on iOS version while on Android it's grey, is there possibility to make it grey on iOS too?
3. Is there possibility of gaining details of phone (more than model,ID,idiom and version of system) through shared part of program ?

I hope i didn't wrote anything stupid. Thx for any help.

UWP App - Immediate Crashes

$
0
0

Hello,

We have a Xamarin.Forms app targeting iOS, Android, and UWP. We're using a PCL for our common Xamarin.Forms code. We're on an older version of the Xamarin.Forms library (version 2.3.4.231).

I recently tried updating the Nuget packages for all projects in our solution to the latest Xamarin.Forms library (version 2.5.0.122203). Everything works fine in iOS and Android. However, when I attempt to run a UWP Debug x86 build on the local machine, the app crashes immediately. I have attached what I see from the event log.

Here is the project.json file (before updating packages):
{
"dependencies": {
"Acr.UserDialogs": "6.3.10",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
"modernhttpclient": "2.4.2",
"PCLCrypto": "2.0.147",
"Plugin.Permissions": "1.2.1",
"Splat": "1.6.2",
"Xam.Plugin.Connectivity": "2.2.12",
"Xam.Plugin.Geolocator": "3.0.4",
"Xam.Plugin.Media": "2.6.1",
"Xamarin.Forms": "2.3.4.231",
"Xamarin.Insights": "1.12.3"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}

And after:
{
"dependencies": {
"Acr.UserDialogs": "6.3.10",
"Microsoft.NETCore.UniversalWindowsPlatform": "6.0.6",
"modernhttpclient": "2.4.2",
"PCLCrypto": "2.0.147",
"Plugin.Permissions": "2.2.1",
"Splat": "1.6.2",
"Xam.Plugin.Connectivity": "3.0.3",
"Xam.Plugin.Geolocator": "4.2.0",
"Xam.Plugin.Media": "3.1.2",
"Xamarin.Forms": "2.5.0.122203",
"Xamarin.Insights": "1.12.3"
},
"frameworks": {
"uap10.0.14393": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}

If I change the Xamarin.Forms dependency back to a version 2.3.XXX variant the app will not immediately crash on startup. However, because a later version of Xamarin.Forms is being used by our PCL, the app doesn't work quite right at runtime (e.g. Device.Runtime is Windows instead of UWP). I also tried 2.4.XXX variants of the Xamarin.Forms dependeny in our UWP app - those fail too.

Is this a known issue? Anybody know how to resolve this?

Thanks.

How to bind Button command to ViewModel and IsEnabled to model (bug?)?

$
0
0

I have a listview created with a data template for the group header and for the item. The listview has an ItemsSource "Weeks" in which there is an array with "items" which will be used to populate the items belonging to the group. Every item has a button which is binding to a value in the "item" model. But the button command is binding to the viewmodel. As soon as I do that, things go wrong. If I set "IsEnabled" to false when the listview is loading, it will not disable the button as soon as I have set the command in my viewmodel or model. If I don't assign the command everything works. If I remove the Command from the XAML, all is well.
The command will execute a check if a value is '0' and then will disable the button("IsEnabled=false"), this works all the time, no matter where the Command is binded/set. It is merely the loading. If the button is disabled after pressing the button, the button is scrolled out of view and then back in, the button is enabled again. So it is really connected to loading/showing the button.

I need to bind the Command to the viewmodel as I believe that is the way to do it and I need to know when the button is pressed so the viewmodel can handle some actions and UI updates.

<Button x:Name="minButton" Text="-" Style="{StaticResource borderlessButton}" IsEnabled="{Binding IsMinButtonEnabled}" Command="{Binding Source={x:Reference Name=PredictView}, Path=BindingContext.MinButton}" CommandParameter="{Binding .}" Grid.Column="1"/>

Is there something I'm doing wrong or is this a bug?


Setting binding in code in a custom control

$
0
0

I am trying to make a simple control that combines an entry and a label.
The binding doesn't work, however, and I don't understand why.
Can anyone help clarify?

Here's my control xaml

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyApp.Custom.Controls.LabelEntry">

    <ContentView.Content>

        <Grid x:Name="cGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Label x:Name="cLabel"
                   Grid.Column="0"/>

            <Entry x:Name="cEntry"
                   Grid.Column="1"/>

        </Grid>

    </ContentView.Content>

</ContentView>

and my control xaml.cs

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class LabelEntry : ContentView
{
    public LabelEntry()
    {
        InitializeComponent();
    }

    #region Binding for LabelText
    public static readonly BindableProperty LabelTextProperty = BindableProperty.Create(
        propertyName: "LabelText",
        returnType: typeof(string),
        declaringType: typeof(LabelEntry),
        defaultValue: "",
        defaultBindingMode: BindingMode.TwoWay,
        propertyChanged: LabelTextPropertyChanged);

    public string LabelText { get; set; }

    private static void LabelTextPropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        var control = (LabelEntry)bindable;
        control.cLabel.Text = newValue?.ToString();
    }
    #endregion

    #region Binding for LabelStyle
    public static readonly BindableProperty LabelStyleProperty = BindableProperty.Create(
        propertyName: "LabelStyle",
        returnType: typeof(Style),
        declaringType: typeof(LabelEntry),
        defaultValue: null,
        defaultBindingMode: BindingMode.TwoWay,
        propertyChanged: LabelStylePropertyChanged);

    public Style LabelStyle { get; set; }

    private static void LabelStylePropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        var control = (LabelEntry)bindable;
        control.cLabel.Style = (Style)newValue;
    }
    #endregion

    #region Binding for EntryText
    public static readonly BindableProperty EntryTextProperty = BindableProperty.Create(
        propertyName: "EntryText",
        returnType: typeof(string),
        declaringType: typeof(LabelEntry),
        defaultValue: "",
        defaultBindingMode: BindingMode.TwoWay,
        propertyChanged: EntryTextPropertyChanged
        );

    public string EntryText
    {
        get => (string)GetValue(EntryTextProperty);
        set => SetValue(EntryTextProperty, value);
    }

    private static void EntryTextPropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        var control = (LabelEntry)bindable;
        control.cEntry.Text = newValue?.ToString();
    }
    #endregion

    #region Binding for EntryPlaceholder
    public static readonly BindableProperty EntryPlaceholderProperty = BindableProperty.Create(
        propertyName: "EntryPlaceholder",
        returnType: typeof(string),
        declaringType: typeof(LabelEntry),
        defaultValue: "",
        defaultBindingMode: BindingMode.TwoWay,
        propertyChanged: EntryPlaceholderPropertyChanged);

    public string EntryPlaceholder { get; set; }

    private static void EntryPlaceholderPropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        var control = (LabelEntry)bindable;
        control.cEntry.Placeholder = newValue?.ToString();
    }
    #endregion

    #region Binding for EntryStyle
    public static readonly BindableProperty EntryStyleProperty = BindableProperty.Create(
        propertyName: "EntryStyle",
        returnType: typeof(Style),
        declaringType: typeof(LabelEntry),
        defaultValue: null,
        defaultBindingMode: BindingMode.TwoWay,
        propertyChanged: EntryStylePropertyChanged);

    public Style EntryStyle { get; set; }

    private static void EntryStylePropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        var control = (LabelEntry)bindable;
        control.cEntry.Style = (Style)newValue;
    }
    #endregion

    #region Binding for GridStyle
    public static readonly BindableProperty GridStyleProperty = BindableProperty.Create(
        propertyName: "GridStyle",
        returnType: typeof(Style),
        declaringType: typeof(LabelEntry),
        defaultValue: null,
        defaultBindingMode: BindingMode.TwoWay,
        propertyChanged: GridStylePropertyChanged);

    public Style GridStyle { get; set; }

    private static void GridStylePropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        var control = (LabelEntry)bindable;
        control.cGrid.Style = (Style)newValue;
    }
    #endregion
}

and how I use the control

<custom:LabelEntry Style="{StaticResource SimpleLabelEntry}"
                       LabelText="Test Label"
                       EntryPlaceholder="Test Placeholder"
                       EntryText="{Binding TestData}"/>

where TestData is a property that implements INotifyPropertyChanged in my view model

Is there any alternative of Volley used in android to call REST services for Xamarin Forms?

$
0
0

I am looking for any alternative of volley in xamarin forms to communicate with REST services. I am currently using HttpClient to communicate with REST services. But now i am looking for some alternative which gives me advantages of volley. I searched but nothing found . If anybody knows please comment.

How to move a button when it is clicked

$
0
0

I have two frames and a button which I have set up in an absolute layout in XAML. The second frame has the IsVisible property set to false. When the button is clicked I would like to move the button down to a new position and set the IsVisible property on the second frame to true. I have tried to use ViewExtensions.TranslateTo() and ViewExtensions.LayoutTo() but it seems to make my button disappear. Anyone know how to move the button to the new position on click?

Custom Editor inside a listview disables on show

$
0
0

Hi,

I have a custom listview using custom viewcells having radio buttons and editor control inside it. On tapping the radio buttons the comment box visibility is toggled (show/hide).
On loading the listview for the first time the editor control visibility is by default hidden. Once the radio buttons are tapped, the editor is displayed. The issue here is that the editor disables when it is shown and no keyboard pops up on tapping it.

It works perfectly fine on Android and IOS versions till 10.3

I am facing this issue with all IOS devices having version 11 and above.

Xamarin Forms v2.5.0.91635

Please help.

Thanks,

Android Toolbar height in Xamarin.Forms

$
0
0

Does anyone know how to get the toolbar height in Xamarin.Forms on Android?

Viewing all 58056 articles
Browse latest View live


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