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

Xamarin Forms Call Screen UI (Free)


Use code in cs file

$
0
0

How do is change this code to use the Source of the Mywebview that is in the cs file

MainPage.xaml





            <ProgressBar Progress="0.2"  
                HorizontalOptions="FillAndExpand"  
                x:Name="progress"  
                ProgressColor="Maroon"    
                IsVisible="True"/>
            <app1:MyWebView Source="https://docs.google.com" WidthRequest="1000" HeightRequest="1000"   Navigating="OnNavigating"  Navigated="OnNavigated"  />
        </StackLayout>

In MainPage.xaml.cs

MyWebView = "https://docs.google.com";

Is not working

How to reset password for login?

$
0
0

After i log in my xamarin page, i want to change my password.
I am new how to make that page using my Api framework.

Thank you.
public async void SignInProcedure(object sender, EventArgs e) {

    User user = new User(Entry_phone.Text, Entry_Password.Text);
    if (user.CheckInformation())
    {
        HttpClient client = new HttpClient();
        var uri = new Uri(string.Format("http://4a99cffe.ngrok.io/api/Login?phone=" + Entry_phone.Text + "&password=" + Entry_Password.Text));
        HttpResponseMessage response; ;
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        response = await client.GetAsync(uri);

        if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
        {
            var errorMessage1 = response.Content.ReadAsStringAsync().Result.Replace("\\", "").Trim(new char[1] { '"' });
            await DisplayAlert("Login", "Log in success", "ok");
            await Navigation.PushAsync(new Customerinfo(Entry_phone.Text));
        }
        else
        {
            var errorMessage1 = response.Content.ReadAsStringAsync().Result.Replace("\\", "").Trim(new char[1] { '"' });
            await DisplayAlert("Login", "", "Again");
        }




        Entry_phone.Text = string.Empty;
        Entry_Password.Text = string.Empty;
    }
    else
    {
        await DisplayAlert("Login", "Not correnct Login information", "ok");
    }

That is my api

[HttpGet]
[ActionName("XAMARIN_Login")]
public HttpResponseMessage Xamarin_Login(string phone, string password)
{
    var user = db.customers.Where(x => x.Phone == phone && x.Password == password).FirstOrDefault();
    if (user == null)
    {
        return Request.CreateResponse(HttpStatusCode.Unauthorized, "Please Enter valid UserName and Password");
    }
    else
    {

        return Request.CreateResponse(HttpStatusCode.Accepted, "Success");
    }
}

How to make an onboarding navigation feature

$
0
0

I would like to create a feature like this where the user puts in information and taps the button to move on to the subsequent pages until they're done. I want there to be a progress bar at the top that corresponds to the page that a user is on (it should be able to go back and forth)
What do you suggest the best way of doing this is? Or is there any GitHub project that has a feature similar to this that I can check out?
https://imgur.com/a/XdjV8a4
Or
https://imgur.com/YOzZIon

How to nest Tab views in Xamarin.Forms

$
0
0

I am trying to create this layout in Xamarin XAML but I cannot figure out how to combine TabView within a TabView. I want 3 main tabs in the bottom and for each page 1-2 subtabs. On each subtab I will need to have a ScrollView(I think thats the right element to use) with list items, which makes it even more complex. Like this picture:

Any idea/example or guidance of how to achieve this?

XF3 solution - iOS - FileNotFound Images.imageset/Contents.json

$
0
0

I haven't dealt with the iOS asset catalog stuff before.
All new XF3 solution. I've added all the images wanted by the Assets.xcassets/AppIcon pane (and what a pain that is).
So I no longer get an error for image120.png not found, etc.

Now I get an error for Images.imageset/Contents.json not found. ANd I agree. When I look on the build mac there is no such directory or file.

So... Now what? What is it looking for to create that Images.imageset? Do I have to add images to an image set whether I have any or not? Does it just not work if you don't have at least a set defined?

Well... Let's try that.
Now it complains there is no Images blah blah. I'm thinking that at one time there was an Images catalog that got deleted... but not fully deleted... so some file someplace thinks its still there. Each new Images catalog is the next number up. So I'm always missing one.

Does anyone know where the list of these catalogs lives so I can manually edit it?

Best way to display images using URL

$
0
0

I am developing an Android app which retrive PC's informations from a database, upload the relative images of the PC to the server and also get back the PC's URL of the images for displaying. Everything works like a charm, for all of the 3 part I use a WCF service, deployed on remote IIS server.

The images are stored in a server's virtual directory, so you can copy the URL and paste it in the browser and the image appear without problems.

As I use a dynamic view of the images, I implemented the method below for creating them:

private void DisplayAttechedIMages(List<string> list_images_url)
{
    for (int i = 0; i < list_images_url.Count; i++)
    {
        Image pic = new Image
        {
            HeightRequest = 250,
            WidthRequest = 150,
            Source = ImageSource.FromUri(new Uri(list_images_url[i])),
        };
    }
}

This is only the part where I create them, now I need to add them to a container, I tried to use Gridinside a ScrollView, but the result isn't good, because the visualization results with low performance (lagging, low response and bad resize).

Also I tried ViewCellinside TableView but the results are pretty the same.

This results could depend by the device?

So what is the best way to display image using the URLs?

Splash screen with Version

$
0
0

On my Splash screen, I want to put the App version for both Android and iOS at the bottom


Getting data from any sound currently playing on an android device?

$
0
0

I am interested to get any sound currently playing on a mobile device, even if it is not playing using the app. Is it possible to monitor the speakers, and get data directly before they play that sound? Like when you plug in the headphones and the speaker stops, but android sends the data to the headset, no matter, where it is playing. If it is, what would be the code?

I did look at this, but this should get only if it is playing or not, and not actuall song data.

https://stackoverflow.com/questions/32833722/xamarin-android-detect-if-audio-is-currently-playing-on-device

Xamarin forms Open map location on external app

$
0
0

Helo,
I'm using xamarin forms and by

Device.OpenUri (new Uri ($ "geo: {Latitud}, {Longitude}"));

I'm opening and external gps navigation. It works for android 9. Application waze start navigate to this position, google mpas appears that position. But on lower android it only open a map application on my current position. (Samsung galaxy s7 android 8, huawey p8 android 6).
Can you help me how to solve this?

Navigation betweens pages

$
0
0

Hello to everyone

I am trying to navigate between two pages,** first:**

private void Page2_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new Page2());
}

Second

async private void Page2_Clicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new Page2());
}

And both send me the follow Error:

System.InvalidOperationException
Mensaje = PushAsync is not supported globally on Android, please use a NavigationPage.

how can I solve it

set index of binding list from another list

$
0
0

Hello,
i am new at xamarin i have an issue and i don't have an idea how to solve it.
assume i have two lists
public class A
{
public int Id { get; set; }
public int refIndx { get; set; }
public string SomeString { get; set; }
}

public class B
{
public string SomeString { get; set; }
.....
}

in xaml :

        <ListView x:Name="FlightList">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid Padding="5">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Frame CornerRadius="10"  
                                   OutlineColor="DarkOrange" 
                                   Padding="0">
                                <StackLayout Grid.Row="0">
                                                <Span Text="{Binding A.SomeString }" /> //this works fine
                                                <Span Text="{Binding b[A.refIndx].SomeString }" /> //nvalid property path syntax                                        
                                </StackLayout>
                            </Frame>
                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

do you have any idea how to achieve this?

regards

Shell TabBar Priority run

$
0
0

hi

<TabBar>

    <Tab Title=" پروفایل من" Icon="User" TabIndex="0">
        <ShellContent ContentTemplate="{DataTemplate page:User}" />
    </Tab>

    <Tab Title=" دسته بندی" Icon="List" TabIndex="1">
        <ShellContent ContentTemplate="{DataTemplate page:Categorie}" />
    </Tab>

    <Tab Title=" صفحه نخست" Icon="Home" TabIndex="2">
        <ShellContent ContentTemplate="{DataTemplate page:Main}" />
    </Tab>

</TabBar>

how run curent page TabIndex="2"?

Set the width of an item inside the collection view?

$
0
0

I am currently trying to set the width of the items inside a CollectionView, this because I intend to check if the screen has more space, I can make my CollectionView a 2 column list instead of 1. However, when I set the property WidthRequest to something in the StackLayout, the behaviour is not the one I expect.

Without the WidthRequest:

With WidthRequest:

Code:

 <ContentPage.Content>
        <Grid RowSpacing="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <CollectionView
                Grid.Row="0"
                ItemsSource="{Binding Items}"
                SelectionMode="None">
                <d:CollectionView.ItemsSource>
                    <x:Array Type="{x:Type models:FighterRowView}">
                        <models:FighterRowView
                            Name="Jason Lee Scott"
                            Id="0" />
                        <models:FighterRowView
                            Name="Tommy Oliver"
                            Id="1"/>
                        <models:FighterRowView
                            Name="Gia Moran"
                            Id="2" />
                        <models:FighterRowView
                            Name="Anubis Doggie Cruger"
                            Id="3" />
                    </x:Array>
                </d:CollectionView.ItemsSource>
                <CollectionView.ItemTemplate>
                    <DataTemplate x:DataType="models:FighterRowView">
                        <StackLayout Spacing="{StaticResource StandardSpacingDouble}" WidthRequest="300">
                            <StackLayout.GestureRecognizers>
                                <TapGestureRecognizer Command="{Binding ClickedCommand}" />
                            </StackLayout.GestureRecognizers>
                            <border:SfBorder
                                Margin="{StaticResource StandardSpacing}"
                                BackgroundColor="{StaticResource PrimaryColor}"
                                BorderColor="{StaticResource ButtonBorderColor}"
                                BorderWidth="{StaticResource RosterBorderWidth}"
                                CornerRadius="{StaticResource RosterCornerRadius}">
                                <Grid ColumnSpacing="0" RowSpacing="0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Label
                                        Grid.Column="0"
                                        Margin="{StaticResource StandardSpacing}"
                                        FontFamily="{DynamicResource MontserratBoldItalic}"
                                        FontSize="Large"
                                        LineBreakMode="WordWrap"
                                        Text="{Binding Name}"
                                        VerticalOptions="Center" />
                                </Grid>
                            </border:SfBorder>
                        </StackLayout>
                    </DataTemplate>
                </CollectionView.ItemTemplate>
            </CollectionView>
            <views:AdControlView
                Grid.Row="1"
                AdUnit="{Binding AdUnit}"
                BackgroundColor="{StaticResource AccentColor}"
                IsVisible="{Binding DisplayAd}" />
        </Grid>
    </ContentPage.Content>

UI question for hierarchical navigation within a modal page

$
0
0

Hi.

I am developing an app that has a main view that is somewhat similar to a Maps app in the sense that it has a 'main' view with very little UI chrome.
One of the buttons in the app invokes a modal page, where a user can create a task of sorts. There are three different sets of information that the user has to fill in in said dialog.

I don't want to make one big cluttered page, so I am wondering what the best UI paradigm that Xamarin supports without a lot of custom controls/renderers would be for this? My initial thought was to use normal hierarchical navigation inside the modal dialog, but modal pages don't support hierarchical navigation, nor am I sure if it'd even been the best user experience.

In other words, the user is presented with a modal page that has three discrete steps of info before it can be 'submitted'. Material UI has the stepper component, https://material-ui.com/components/steppers/, I could of course roll something like that but I'd also like for the app to use standard iOS and Android paradigms.
What would you guys recommend?

Thanks!


How can I create FlexLayout in OnAppearing method

$
0
0

I need to create FlexLayout based on content from server. I'm using method like this:

private static FlexLayout CreateFlexLayout(IEnumerable<Item> Items)    
{
     //create layout based on Items collection
}

And trying to call it like this:

    protected override void OnAppearing()
    {
        base.OnAppearing();
        if (!viewModel.Items.Any())
        {
            viewModel.LoadItemsCommand.Execute(null);
            //loading items from server
        }
        this.Content = CreateFlexLayout(viewModel.Items);
        //trying to update Page
    }

It's not working. Page is clean. Content from the server is different any time so I can't build interface in Xaml and bind Items, but I can't recognize how to update Page from Code Behind.

RefreshView not working in CollectionView

$
0
0


Is this true?
Because the data is not displayed at all

Displaying structured textual data from JSON, into a listview using cell and two labels

$
0
0

Hi,

My apologies this maybe a long one. I am building an application which will display some structured text into a list view. The text comes from a JSON file and I am using Newton JSON to parse that. The structure of the JSON file is as follows. Generally the depth will not exceed more than 3. I am only displaying the POINTS section of data, everything is selected before (so users will click on Parts -> Sections -> Then points will show). The points is the primary text which needs a nice structure in a list view cell.

{
    "Name": "TITLE",
    "Year": 1400,
    "Created": "2019-12-27",
    "Updated": "2019-12-27",
    "Parts": [
        {
            "Part": "Part 10",
            "Name": "SOME NAME",
            "Sections": [
                {
                    "Name": "SOME SECTIONS WITH CONTENT",
                    "Section": "1",
                    "Points": [
                        {
                            "Point": "(1)",
                            "Content": "SOME NESTED CONTENT",
                            "Children": [
                                {
                                    "Point": "(A)",
                                    "Content": "SOME NESTED NESTED CONTENT",
                                    "Children": []
                                },
                            ]
                        },
                        {
                            "Point": "(2)",
                            "Content": "SOME NESTED CONTENT",
                            "Children": []
                        },
                        {
                            "Point": "(3)",
                            "Content": "SOME NESTED CONTENT",
                            "Children": []
                        }
                    ]
                }
            ]}
    ]
}

Currently the XAML looks like this.

        <ListView x:Name="ListPoints" CachingStrategy="RecycleElement" HasUnevenRows="True">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout x:Name="Content" Orientation="Horizontal" Padding="10">
                                <Label x:Name="ListPoint" Text="{Binding Point}" MinimumWidthRequest="30"/>
                                <Label x:Name="ListContent" Text="{Binding Content}"/>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

However, this only shows the first level, and not the children or nested children of POINTS. What I want to do is dynamically added the stack layout for each point. How could I accomplish this?

The C# code currently assigns the points collection like this.
ListPoints.ItemsSource = sections.Points;

I have been trying to solve this issue for the past 3 days now to now avail, I cannot seem to find a decent solution. I have partially got it working using Android and a custom render, but that messes things up on scrolling, I am trying to get a full solution in Xamarin Forms, hopefully there should be a way of doing what I want.

The screenshot below shows what I want to achieve, that was doing using Xamarin.Android using custom list view render, it caused issues so looking for a full solution in Forms. The content from point (1) to (iii) is one big view cell, using multiple labels to define points and content. That's what I want, currently I only get the first point and content when using Xamarin Forms.

Ways to wait for result from a Page / Modal

$
0
0

Hello everyone,

I'm trying to figure out an elegant / effective way to wait for a result from a Page or Modal before continuing

I have tried using:

Events:

public class SomePage : ContentPage
{
    public event EventHandler<ResultsEventHandlerArgs> OnResults;

    public SomePage ()
    {
              //...
        }
}


// Somewhere in the application

SomePage page = new SomePage ();

page.OnResults += async (object sender, ResultsEventHandlerArgs e) => {
    await Navigation.PopModalAsync();
    //Do something with the results in e
};

await Navigation.PushModalAsync (page);

Pro's:

  • Logic is not coupled
  • Can use that (modal) Page 'anywhere'

Con's:

  • Forgetting to unsubscribe from the event can cause the page to stay in memory longer than expected

TaskCompletionSource:

In our application logic after logging in some users had to choose some options before continuing to the 'main' app and others didn't.
So I used some thing like

public class App : Application
{
     public App()
     {
           //Some logic

          if(ExtraOptions)
          {
               TaskCompletionSource tcs = new TaskCompletionSource();
               MainPage = new SomePage(tcs);
               //In the SomePage after the options are chosen -> tcs.SetResult();
               var task = await tcs.Task;
               var result = task.Result;
               task.Dispose();
               //Do something with the result
          }

          //Load the 'Main' app
         MainPage = new MasterDetailPage();
     }
}

And I tried combinations of both events and TaskCompletionSource, but I'm unsure if this is an acceptable way to approach this problem.

This is written from memory so there might be some typo's etc. in the examples above

Are there other ways I can take or improvements I can make to achieve this behaviour (The waiting for a result before continuing) ?

Xamarin Forms 4.0 Shell Navigation - Login Page

$
0
0

I am trying to implement a simple login page in my app using shell. I check some posts but none of them could fix my problem.

In my app.xaml.cs I have two options: if user was logged => MainPage = new AppShell(); otherwise MainPage = new Login(); That approach appears to work fine, and I can see the right page after successfull logon.

The shell navigation page have a tab with a logout page, and here is my problem. If I use App.Current.MainPage = new Login(); the page overlap the content of my current shell page!

What´s the best approach to implement login page using shell navigation? Anyone know where can I find a sample project?

Any help will be appreciate.

Viewing all 77050 articles
Browse latest View live


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