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

How to use Spinner in Xamarin Forms

$
0
0

I want to use android Spinner in Xamarin Forms application. How can I do that?


How to get Navigation back button event in Xamarin forms

$
0
0

In my project on one page there is a form to add products.
if user doesn't save the details and pressed back button, at that time I want to display the action sheet having Discard, Save, Cancel options.
I'm unable to get the back button pressed event.
I'm working in Xamarin studio and used cross platform with xamarin form

I've already tried OnBackButtonPressed event but it doesn't get call

protected override bool OnBackButtonPressed()
{

Device.BeginInvokeOnMainThread(async() => {
    var result = await DisplayActionSheet("Action","Cancel",null,"Discard","Save");
        //if (result) await this.Navigation.PopAsync(); // or anything else
    });

return base.OnBackButtonPressed();

}

Show local downloaded content with hybridwebview

$
0
0

We have a magazine app which downloads HTML pages and displays it in multiple views. In our current code it's using UIwebviews, because of rendering problems we need to upgrade to the WKwebview. The new updated Hybridwebview code is supporting this.

The problem is that we are having issues to get it working. When requesting an online URL it's ok, local URL's are not working and displaying blank pages. The path is correct, files are there, but the screen is keep staying blank.

We already scrolled through multiple forms but we can't find a straight answer.

Could anyone point us in the right direction. Are there maybe any restrictions we don't know about. Keep in mind we don't bundle the HTML content when creating the App. The HTML content is downloaded by the user.

  • In WKwebview, what is the correct folder to store downloaded content?
  • Do we need to set specific settings to acces local content?
  • What is the correct way to request a local file?

Hope someone can point us out in the right direction.

UWP - Immediate crash in release mode

$
0
0

I have a forms solution, it runs fine in debug but crashes immediately in release mode, it doesn’t even get to my MainPage constructor:

    Unhandled exception at 0x54D62408 (Windows.UI.Xaml.dll) in SmartCart.UWP.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x0D6594E8, 0x00000003).
    Unhandled exception at 0x76341104 (combase.dll) in SmartCart.UWP.exe: 0xC0000602:  A fail fast exception occurred. Exception handlers will not be invoked and the process will be terminated immediately.
    STATUS_STACK_BUFFER_OVERRUN encountered
    The program '[11592] SmartCart.UWP.exe' has exited with code -1073740791 (0xc0000409).

When I build everything in release except for my UWP project the project will run.

Is this an issue with forms? Has anyone build and run UWP Forms in release mode?

PCL Use of Windows.Security.Cryptography.Core

$
0
0

Is it possible to use the Windows.Security.Cryptography.Core in the shared library of a cross-platform app (e.g. is it dependent on the Windows core?) or is there an equivalent library that I should use?

How to navigate back from browser to app once i completed download.

$
0
0

Device.OpenUri("SomeUrltodownload");

i used this command to download file from url.But i can't navigate back to app once download completed.can some one help me on this?
Thanks In Advance

Why xamarin website is not loading

$
0
0

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

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.

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.

How to get Navigation back button event in Xamarin forms

$
0
0

In my project on one page there is a form to add products.
if user doesn't save the details and pressed back button, at that time I want to display the action sheet having Discard, Save, Cancel options.
I'm unable to get the back button pressed event.
I'm working in Xamarin studio and used cross platform with xamarin form

I've already tried OnBackButtonPressed event but it doesn't get call

protected override bool OnBackButtonPressed()
{

Device.BeginInvokeOnMainThread(async() => {
    var result = await DisplayActionSheet("Action","Cancel",null,"Discard","Save");
        //if (result) await this.Navigation.PopAsync(); // or anything else
    });

return base.OnBackButtonPressed();

}

Show local downloaded content with hybridwebview

$
0
0

We have a magazine app which downloads HTML pages and displays it in multiple views. In our current code it's using UIwebviews, because of rendering problems we need to upgrade to the WKwebview. The new updated Hybridwebview code is supporting this.

The problem is that we are having issues to get it working. When requesting an online URL it's ok, local URL's are not working and displaying blank pages. The path is correct, files are there, but the screen is keep staying blank.

We already scrolled through multiple forms but we can't find a straight answer.

Could anyone point us in the right direction. Are there maybe any restrictions we don't know about. Keep in mind we don't bundle the HTML content when creating the App. The HTML content is downloaded by the user.

  • In WKwebview, what is the correct folder to store downloaded content?
  • Do we need to set specific settings to acces local content?
  • What is the correct way to request a local file?

Hope someone can point us out in the right direction.

UWP - Immediate crash in release mode

$
0
0

I have a forms solution, it runs fine in debug but crashes immediately in release mode, it doesn’t even get to my MainPage constructor:

    Unhandled exception at 0x54D62408 (Windows.UI.Xaml.dll) in SmartCart.UWP.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x0D6594E8, 0x00000003).
    Unhandled exception at 0x76341104 (combase.dll) in SmartCart.UWP.exe: 0xC0000602:  A fail fast exception occurred. Exception handlers will not be invoked and the process will be terminated immediately.
    STATUS_STACK_BUFFER_OVERRUN encountered
    The program '[11592] SmartCart.UWP.exe' has exited with code -1073740791 (0xc0000409).

When I build everything in release except for my UWP project the project will run.

Is this an issue with forms? Has anyone build and run UWP Forms in release mode?

PCL Use of Windows.Security.Cryptography.Core

$
0
0

Is it possible to use the Windows.Security.Cryptography.Core in the shared library of a cross-platform app (e.g. is it dependent on the Windows core?) or is there an equivalent library that I should use?


How to navigate back from browser to app once i completed download.

$
0
0

Device.OpenUri("SomeUrltodownload");

i used this command to download file from url.But i can't navigate back to app once download completed.can some one help me on this?
Thanks In Advance

[Solved] Device.StartTimer doesn't stop and gives random values

$
0
0

My timer has an issue, if I click on it around 3 times really fast ten the timer starts going backwards and forwards, its weird. My goal is so once I press on one listview item the other timer stops, or if I press on the same listview item that the timer pauses. But no luck, this is my code:

`
namespace floatingb.ViewModel
{
[AddINotifyPropertyChangedInterface]
public class TaskPageViewModel
{
//for navigation purposes
public INavigation _navigation;
public INavigation nav;

    //dbconnector
    private static DatabaseHelper dbhelper;

    //command to add item to listview
    private ICommand Addbtn;

    //command to save teh item to database and observablecollection
    private ICommand save;

    //command to delete task that the user has pressed on.
    private ICommand _DeleteSingleTask;

    private ICommand StartPlayOrPauseButton;

    private ObservableCollection<UserModel> items;
    private List<UserModel> _itemsList;

    //retrieve the item name in the UserModel class
    private UserModel _itemName { get; set; }

    //this is what will hold the listview items
    private UserModel _SelectedListViewItem { get; set; }

    //current task
    private string task;

    private string TimeStarted { get; set; }      

    //null because might not need to pass with parameter
    public TaskPageViewModel(INavigation navigation = null)
    {
        //set the nevigation
        nav = navigation;

        //create new db
        CreateNewDb();
    }

    //create new db
    public static DatabaseHelper CreateNewDb()
    {
        //if null create new database
        if (dbhelper == null)
        {
            dbhelper = new DatabaseHelper();
        }

        return dbhelper;
    }

    //add button to add new task
    public ICommand AddButton
    {
        get => Addbtn ?? (Addbtn = new Command(() =>
        {
            nav.PushAsync(new NewItemAddView(this));
        }));
    }

    //delete listview item task both from db and from observablecollection
    public ICommand DeleteSingleTask
    {
        get => _DeleteSingleTask ?? (_DeleteSingleTask = new Command((UserModel) =>
        {
            //get selected listview item and convert it to userModel
            _SelectedListViewItem = (UserModel)UserModel;

            //remove from list
            ListItems.Remove((UserModel)UserModel);

            //   MessagingCenter.Send(this, "xyz", ListItems.Count);

            dbhelper.DeleteIndividualItem(_SelectedListViewItem.Id);

        }));
    }

    //add task
    public ICommand AddTask
    {
        get => save ?? (save = new Command(() =>
        {
            //current task
            var currentTask = Task;

            //current time on phone
            var currentTime = DateTime.Now.ToString("HH:mm");

            //create new user model
            UserModel task = new UserModel
            {
                //set the item name to current task and datetimeset to current time
                ItemName = currentTask,
                DateTimeSet = currentTime,
                SelectedColor = "#4286f4"
            };
            //add to listitems (ObservableCollection
            ListItems.Add(task);

            //insert in db the task
            dbhelper.InsertItem(task);
        }));
    }

    public ICommand PlayOrPauseButtonPressed
    {
        get => StartPlayOrPauseButton ?? (StartPlayOrPauseButton = new Command((UserModel) =>
        {
            //var SelectedItemId = ListItems.Where(i => i.Id == (int)UserModel);
            UserModel selectedUser = (UserModel)UserModel;

            //if not equal to purple colour set it to purple colour
            if(!selectedUser.DefaultColor.Equals("#f420db"))
            {
                selectedUser.DefaultColor = "#f420db";
            }

            //update database to add new colour value
            dbhelper.UpdateItem(selectedUser);

            //start the timer
            StartTimer(selectedUser);
        }));
    }

    public string MyTextColor
    {
        get { return "#42f4ad"; }
    }

    //return the task
    public string Task
    {
        get { return task; }
        set
        {
            task = value;
        }
    }

    //return only item name
    public string ItemName
    {
        get => _itemName.ItemName;
        set
        {
            _itemName.ItemName = value;

        }
    }

    public string TimeStart
    {
        get => TimeStarted;
        set
        {
            TimeStarted = value;
        }
    }


    public UserModel SelectedListViewItem
    {
        get { return _SelectedListViewItem; }
        set
        {
            if (_SelectedListViewItem != null)
                _SelectedListViewItem.Selected = false;

            _SelectedListViewItem = value;
            //set to false first incase its true already.
            //   _SelectedListViewItem.Selected = false;

            //if bool is item selected is false
            if (_SelectedListViewItem.Selected == false)
            {
                // then set the state to true since the item has been pressed.
                //     _SelectedListViewItem.Selected = true;

                //MessagingCenter.Send<TaskPageViewModel, string>(this, "Detail", _SelectedListViewItem.ItemName);
            }

        }
    }

    //this is used to store the "previously" selected item
    UserModel um = new UserModel();

    //once the user presses on a listview item then start the timer
    public void StartTimer(UserModel selectedListViewItem)
    {
        //new stopwatch object to start time
        Stopwatch timeElapsed = new Stopwatch();

        //new date time 
        DateTime dt = new DateTime();

        //set to current date time
        dt = DateTime.Now;

        //used to check if time of day is AM/PM
        string IsAmOrPM = "";

        //store the total elapsed time because when we stop timer so text can stay
        string totalElapsedTime = "";

        bool hasDeviceTimerStopped = false;

        //this checks to see if there is no content inside of this UserModel
        if (um.Id == 0)
        {
            um = selectedListViewItem;
        }

        //if objects arent equal then do the following
        if (!um.Equals(selectedListViewItem))
        {
            //stop timer temporarily since new item has started
            timeElapsed.Stop();

            //set this variable to the new item since new item has been selected
            um = selectedListViewItem;

            //set to current time spent on item
            um.DateTimeSet = totalElapsedTime;


        }

        //if greater than 19 set to pm
        if(dt.Hour > 19)
        {
            IsAmOrPM = "PM";
        }
        //if less than 19 set to am
        else if(dt.Hour < 19)
        {
            IsAmOrPM = "AM";
        }

        if (um.Equals(selectedListViewItem) && hasDeviceTimerStopped == false)
        {
            //start the stopwatch
            timeElapsed.Start();

            //need to make a bool here that allows only once for timer to start make a if statement here

            //start timer                
            StartTimer(selectedListViewItem, timeElapsed, IsAmOrPM, hasDeviceTimerStopped);
        }


    }

    public void StartTimer(UserModel u, Stopwatch s,string ampm, bool timerStopped)
    {
            Device.StartTimer(TimeSpan.FromMilliseconds(1000), () =>
            {
                //update text to show the current time spent on task.
                u.DateTimeSet = string.Format("{0:00}:{1:00}:{2:00} ", s.Elapsed.Hours, s.Elapsed.Minutes, s.Elapsed.Seconds) + ampm;

                //if objects are not same then this means user has selected a new object and must stop the timer
                if (u.Id != um.Id)
                {
                    timerStopped = true;
                    u.DateTimeSet = "test";
                    return false;
                }

                //return true since objects are same
                return true;
            });           

    }

    //observablecollection that contains UserModel items
    public ObservableCollection<UserModel> ListItems
    {
        get => items;
        set
        {
            items = value;
        }
    }

    //bind items to listview
    public void BindItems()
    {
        _itemsList = dbhelper.GetAllItemsData().ToList();

        ListItems = new ObservableCollection<UserModel>(_itemsList);


        //loop through list items and if id is less than 0 set it to default colour which is below (this is used so when the user leaves this page the timer stops)
        for (int i = 0; i < items.Count; i++)
        {
            if (items[i].Id > 0)
            {
                items[i].DefaultColor = "#59f441";
            }
        }
    }
}

}

`

why a button is automatically disable .

$
0
0

i am using the button in side the frame . and frame is using in side the grid. i don't know why button is automatically disable. ..please tell the possible suggestion.

Popup windows within a webview?

$
0
0

Does anyone know what kind of support there is for popup windows in webview? We are opening some intranet links within a webview and a new package we have is using javascript to open up it's own styled window to show some elearning courses. Everything looks fine if we open in a native mobile browser but webview isn't handling these very well.

Any help would be appreciated.

Dynamic ListView with TextCells

$
0
0

Hey,

I'd like to to create a ListView with a dynamic amount of items (TextCells) in it. Sometimes the ListView needs to contain 5 TextCells, sometimes it needs to contain more, ... How can I achieve that? Creating a ListView is fairly simple, but I am not sure how to add a TextCell to it.

Cheers!

Viewing all 77050 articles
Browse latest View live


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