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

Need A Camera View Of The Background Without The Camera Buttons

$
0
0

The Camera when opened does capture the background which I want but with that comes the buttons to take a snapshot. I need those buttons hidden. All that is needed is the view. Is there anyway to hide the camera buttons and/or an alternative solution? All that is needed is for the user to see a view of the background but that is it.


Trouble with images and lists with images

$
0
0

So, one page I'm trying to set an image to fill the background and stretch. everywhere i read " Aspect="Fill"" is suppose to do it but my image just sits in the top left. i can't figure out why.

<AbsoluteLayout>
        <Image Source="{local:ImageResource Emu_alexandra_park.png}" Aspect="Fill"/>
        <Label Text="Welcome to &#x0a;The Bundy Book&#x0a; App!" FontSize="Large" TextColor="Red"  XAlign="Center"
               AbsoluteLayout.LayoutBounds=".5,.4" AbsoluteLayout.LayoutFlags="PositionProportional"/>
        <Button
            x:Name="ExploreButton"
            Text=" Explore "
            TextColor="White"
            BackgroundColor="#007Aff"
            BorderRadius="10"
            AbsoluteLayout.LayoutBounds=".5,.75" AbsoluteLayout.LayoutFlags="PositionProportional"
            Clicked="Button_clicked"/>
    </AbsoluteLayout>

another issue im having is having a list row fill to fit the image. The images are either crushed or overlap i can't see how to make each image fill the space.
also "Image1" has it's width stretched to fill the width of the phone but the hight of the image is cropped out and i lose half my image.

    <ScrollView>
            <StackLayout x:Name="singlePlaceView" Margin="20,10,20,10">
                <Label  x:Name="Title"
                    Text="{Binding Name}" FontSize="Large" XAlign="Center"
                    HorizontalOptions="Center" TextColor="Red"/>
                <Image x:Name="Image1" Source="{Binding Image1Source}" Aspect="AspectFill"/>
                <Label  x:Name="Description1"
                    Text="{Binding Description1}" TextColor="DarkBlue"
                HorizontalOptions="CenterAndExpand" />
                <Image x:Name="Image2" Source="{Binding Image2Source}" Aspect="AspectFill" HorizontalOptions="CenterAndExpand"/>
                <Label  x:Name="Description2"
                    Text="{Binding Description2}" TextColor="DarkBlue"
                HorizontalOptions="CenterAndExpand" />
                <ListView x:Name="ListOfAdds" ItemSelected="OnAddItemSelected" HasUnevenRows="True">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <StackLayout>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>
                                        <Image Source="{Binding ImageSource}" Aspect="AspectFill"/>
                                    </Grid>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </StackLayout>
        </ScrollView>

how do i make an image fill the background?
how do i get an image to take up it's actual highet and width? please note this is a template page so must be usable with different size images
how do i get the last question working inside a list view?
also, how do i stop all the excess white space created from a list view? especailly if the list ends up empty. its a template and not all events adds at the bottom. I say adds by they are more like coupons/discounts.

listView binding

$
0
0

How to Bind the ListView with an Observablecollection type where the type itself an observable collection.
My MVVM like below

ViewModel

 public  class OrdersViewModel
{
    public ObservableCollection<Order> Orders{ get; set; }

    public OrdersViewModel()
    {

        Orders = new ObservableCollection<Order> { new Order(),new Order(),new Order()};
    }


}

Models:

public class Order:INotifyPropertyChanged
{
    public ObservableCollection<OrderItem> OrderItems { get;  set; }


    public Order()
    {
        OrderItems = new ObservableCollection<OrderItem> { new OrderItem("xxxx", "2", "200"),
                                                            new OrderItem("yyyy", "1", "500"),
                                                            new OrderItem("zzzz", "1", "400")
                                                           };
        OrderId =( new Guid()).ToString();

    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged(string propertyName)
    {
        var changed = PropertyChanged;
        if(changed != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

public class OrderItem
{

    public string OrderITemName { get;  set; }

    public string Units { get; set; }

    public  string UnitPricePerItem { get; set; }

    public OrderItem(string _orderITemName,string _units,string  _unitPricePerItem)
    {
        OrderITemName = _orderITemName;
        Units = _units;
        UnitPricePerItem = _unitPricePerItem;
    }

}

View

<ContentPage.BindingContext>
    <local:OrdersViewModel />
</ContentPage.BindingContext>
<ContentPage.Content>        
    <StackLayout>          
        <ListView  x:Name="OrdersListView"  ItemsSource="{Binding  Orders}"  >
            <ListView.ItemTemplate >
                <DataTemplate >
                    <ViewCell>
                        <StackLayout>
                            <Label x:Name="OrderITemName" Text="{Binding OrderITemName}" />
                            <Label x:Name="Units" Text="{Binding Units}" />
                            <Label x:Name="UnitPricePerItem" Text="{Binding UnitPricePerItem}" />
                        </StackLayout>                           
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>          
</ContentPage.Content>

How can I change Maps pin color on click and then revert back to red when another pin's clicked?

$
0
0

I have several pins on my map. I have a pin clicked event handler which changes the pin color to blue when clicked. How do I revert the pin's color to red when another pin is clicked? While at the same time changing the other pin's color to blue?

What is MessagingCenter ,why we use and how to implement ?

$
0
0

Hello guys i am xamarin developer but really i don't understand
What is MessagingCenter, where we use and why needs in xamarin app , So can you all Please clarify.

Why xamarin website is not loading

$
0
0

xamarin website is not loading any reason
developer.xamarin. dotcom/samples-all/

How can I make my Entry empty as the default value ?- its mvvm and the fields are binded to integers

How can I identify the assemblies referenced by my app, at run-time?

$
0
0

I would like to be able to report the version numbers etc of all assemblies referenced by my app. If I was doing this on a Windows desktop, I would make use of Assembly.GetReferencedAssemblies(). However, that doesn't seem to be present when I try it from my XF app, even if done in the WinPhone-specific project.

Can anybody advise please on how I can get the collection of assemblies referenced by a XF app please?

Many thanks,

John H.


Errors when adding GooglePlayServices Base.

$
0
0

Hello,

I am trying to add the GooglePlayServices.Base package to my project but I keep getting errors when doing this. This is my error:

Attempting to gather dependency information for package 'Xamarin.GooglePlayServices.Base.32.961.0' with respect to project 'SNIP', targeting 'MonoAndroid,Version=v6.0'
Attempting to resolve dependencies for package 'Xamarin.GooglePlayServices.Base.32.961.0' with DependencyBehavior 'Lowest'
Unable to find a version of 'Xamarin.Android.Support.v4' that is compatible with 'Xamarin.Android.Support.Animated.Vector.Drawable 23.3.0 constraint: Xamarin.Android.Support.v4 (= 23.3.0)', 'Xamarin.Android.Support.Design 23.3.0 constraint: Xamarin.Android.Support.v4 (= 23.3.0)', 'Xamarin.Android.Support.v7.AppCompat 23.3.0 constraint: Xamarin.Android.Support.v4 (= 23.3.0)', 'Xamarin.Android.Support.v7.MediaRouter 23.3.0 constraint: Xamarin.Android.Support.v4 (= 23.3.0)', 'Xamarin.Android.Support.v7.RecyclerView 23.3.0 constraint: Xamarin.Android.Support.v4 (= 23.3.0)', 'Xamarin.Android.Support.Vector.Drawable 23.3.0 constraint: Xamarin.Android.Support.v4 (= 23.3.0)', 'Xamarin.Forms 2.3.3.175 constraint: Xamarin.Android.Support.v4 (= 23.3.0)', 'Xamarin.GooglePlayServices.Basement 32.961.0 constraint: Xamarin.Android.Support.v4 (>= 24.2.1)'.

Anyone knows how to fix this?

Best regards,
Luca Panjer

Transfert an SQLLite Database

$
0
0

Hello,
How to transfert by Wifi a database from a Desktop to a mobile to be used in a Xamarin application and which is belong to the user ?
Thx,
Christophe

Issue in login logout page navigation due to Hardware back button

$
0
0

I have created a simple login and registration app consuming webApi services and it is developed using MVVM model. I have not written a single line of code in somepage.xaml.cs file. After the user logs into the system the he is navigated to homepage but if i press the hardware back button it again goes to login page.
I have searched a bit on this issue and found out OnBackButtonPressed(). It has to be used in xaml.cs . But instead of hitting OnBackButtonPressed() on hardware hit it is not hitting.
It is instead hitting on the toolbar item logout button.

Infinite scrolling?

$
0
0

Is there a clean way to do an infinite scrolling with a listview? and with a grid?

NullReferenceException on DependencyService

$
0
0

I'm trying to implement Bluetooth on Android, but DependencyService.Get<IBluetooth>().Test() is throwing a NullReferenceException and I cannot figure out why. I think I'm doing everything right. My app is called MyApp. MyApp.Android references MyApp. I have a MyApp.iOS but it is only stubbed out and not set to compile.

MyApp\Home.xaml.cs:

var result = DependencyService.Get<IBluetooth>().Test(); //Debugger fails here, DependencyService.Get() is null.

MyApp\IBluetooth.cs:

namespace MyApp {
    public interface IBluetooth {
        bool Test();
    }
}

MyApp.Android\BluetoothAndroid.cs:

[assembly: Xamarin.Forms.Dependency(typeof(BluetoothAndroid))]
namespace MyApp.Droid {
    public class BluetoothAndroid : IBluetooth {
        bool Test() {
            BluetoothAdapter ba = BluetoothAdapter.DefaultAdapter;
            if (ba == null) return false;
            if (!ba.IsEnabled) return false;
            return true; //Incomplete method, just for testing
        }
    }
}

In my searching around I see lots of warnings to "register" the service but people either never say how or say to write this:

DependencyService.Register<SampleApp.Droid.Services.AddressBook>();

but do not say where that line of code goes. Also, I have not been able to determine if the [assembly] line is a way of registering the service.

My code was originally modeled after Stack Overflow answer /a/44126899/10122542 (I can't post links) about multi-platform toast notifications which actually did work for me briefly but has not in weeks and I cannot fathom why it doesn't. DependencyService.Get<IMessage>().ShortAlert("test") always yields a NullReferenceException!

Where is my code wrong? Thank you for your help!

ProgressBar .ProgressTo only works on some devices

$
0
0

Hello,

New here so apologies in advance!

Got the ProgressBar working fine on Emulator and selected devices (Two different model of Sony Xperia running Android 8.0), however my Galaxy S9 this .ProgressTo doesn't work at all.

I managed to fix the buttons which had a similar issue (Worked on all except my Galaxy S9) where button events such as .IsEnabled wasn't changing, by using Device.BeginInvokeOnMainThread

But I'm a bit stuck on how I can get something similar to work for the .ProgressTo; as I assume it would need to be updated by frame?

Thanks!

Edit: Got something similar working via this link;

/questions/36149290/xamarin-forms-progressbar-stop However may not be the most efficient way?

ListView items do not update until list is tapped (Android)

$
0
0

I'm having a recurring issue with an app I am developing. I have several ListViews (with custom ViewCells) with ItemSource bound to ObservableCollections within view models. In every case, when the ListView initially loads, it remains completely blank until it is tapped, at which point all the items load. When changing the source (for example when filtering the items), again there is no change until the screen is tapped.

I would post images showing this but I "have to be around for a little while longer before you can post links".

Both the model and ViewModel implement INotifyPropertyChanged. Is there anything that might be causing this to occur? This issue is specific to Android; I'm not experiencing this on iOS.


Touches events are not fired on Mac

$
0
0

Hi,
I need to get coordinates of user touch on Mac. I created a custom renderer deriving from ViewRenderer. I created a class that derives from NSClickRecognizer and override TouchesBegan, TouchesCancelled, TouchesMoved and TouchesEnded methods but none of them are fired when user press the view. When I add a recognizer with action in constructor, the action is raised but I am not able to get coordinates.
The code looks like this

public class ViewGesturesRenderer : ViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);
            var tapGestureRecognizer = new TapGestureRecognizer();
            if (e.OldElement == null)
            {
                this.AddGestureRecognizer(tapGestureRecognizer);
                this.AddGestureRecognizer(new TapGestureRecognizer(() =>
                {
                    //this fires correctly
                }));
            }
        }

        public class TapGestureRecognizer : NSClickGestureRecognizer
        {
            public TapGestureRecognizer(Action action) : base(action) { }
            public TapGestureRecognizer() { }
            public override void TouchesBegan(NSEvent touchEvent)
            {
                //not fired
                base.TouchesBegan(touchEvent);
            }
            public override void TouchesCancelled(NSEvent touchEvent)
            {
                //not fired
                base.TouchesCancelled(touchEvent);
            }
            public override void TouchesMoved(NSEvent touchEvent)
            {
                //not fired
                base.TouchesMoved(touchEvent);
            }
            public override void TouchesEnded(NSEvent touchEvent)
            {
                //not fired
                base.TouchesEnded(touchEvent);
            }
        }
    }

Thanks,
Martin

Xamarin Forms (.NETStandard 2) iOS, Android, UWP Barcode Scanning - Bluetooth Motorola Symbol CS3000

$
0
0

I am trying to implement barcode scanning with this scanner for our Xamarin.Forms app.

Xamarin.Forms with .NET Standard 2.0 iOS, Android, UWP
Motorola Symbol CS3000 bluetooth barcode scanner

Anyone who can provide any useful links, resources, code, help?

Do you have support LINQ Dynamic Query in PCL Project ?

$
0
0

Hi,
I am writing a query dynamically and try to use in Linq but its not accessable System.Linq.Dynamic namesapce in PCL Project .

Could please let me know how to achive this ?

Force user to enable location services

$
0
0

I have an application that uses location services extensively. I dont want the users to be able to access any functionality unless location services are enabled. The problem I am running into is where do I prompt the users to enable in the lifecycle of the application and essentially halt any navigation etc until they have selected to enable or not? I assumed that I could do this is app.xaml but unsure of how i would proceed there. Any help is appreciated.

Design help for my xamarin.forms app

$
0
0

Hi! Im developing a xamarin.forms app that present data to the users from a large arabic book. Currently im storing the book data in a folder structure in text files with each folder containing the book data for each chapter of the book. I was thinking about creating a service that uses a MongoDB database and store the data in MongoDB. Is a document DB a good design choice for data storage for my application? I have also been thinking about leaving the data files as they are in the folder structure and ship the application with the data, thereby enabling users to use the application offline without having to use the data service to get the book data. Which of these two solutions would be good for my app?

Any suggestions will be valuable.

Viewing all 77050 articles
Browse latest View live