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

Error while implementing Map.

$
0
0

Hello guys,
I am facing an error while implementing maps in my application. I have attached an image. I have enabled both the services, still the problem is there. Is there any other settings to do ?


Can you please post example for RelativeLayout.BoundsConstraint

$
0
0

I would like to have view bound to bottom of screen and to top of view. Similar to iOS constrains (autolayout) so width = frame width, top is bound to top view bottom, and bottom will be parent bottom.

Currently I have: see attached pdf, as far as this stupid discussion does not allow me to post codes here

So I am interested to set Stack Layout bottom to ContentPage bottom, and ideally StackLayout Top to Image (named=logo) bottom. Currently there is workaround of adding constant there...

Add reference to Interface class in Main.cs

$
0
0

Hi

I have a interface ( iCamera ). In Xamarin.Droid folder, I included a referece to my interface in MainActivity.cs file. Works fine.

But, I don't know how include a Interface Reference in Xamarin.iOS. How can I add a reference to the interface ICamera in the Main.cs file?

Content Page with tabbed page sub section

$
0
0

I have an app that has some basic information (a couple of labels) and an entry field.
Below this I have 2 sets of data: ListView with user actions completed, and an Entry field (although this may change) with data being read from a web service which will be updated over time.
The user will only want to see their actions, or the web service data, so I thought I could have a tabbed section on the lower half of the page. They will always want to see the info at the top and the top Entry field needs to have focus.

What is the best way to handle this using only xaml. There will only ever be 2 tabs in the lower section.

I was hoping something like this, but I can't figure out how to get the TabbedPage, and its children to work. I'm sure I'm getting the xmlns and the x:Class mucked up. Maybe I don't need them at all :

    <ContentPage>
        <Label />
        <Entry />
        <TabbedPage>
            <TabbedPage.Children>
                <Tab Title="Tab 1" />
                <Tab Title="Tab 2" />
            </TabbedPage.Children>
        </TabbedPage>
    </ContentPage>

Any clues would be greatly appreciated.

Thanks

Navigation problems

$
0
0

Hello everybody, I'm new to the forum; I'm developing my first application using xamarin forms and I have a browsing problem.

Starting from the default template of a master-detail cross platform application, I modify the model adding a property that indicates the type of page to load.

After that when I select from one page from the list I would instantiate the page of the respective type and pass the current model to the new one.

async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
{
var item = args.SelectedItem as Item;
if (item == null)
return;

        var page = Activator.CreateInstance(item.TargetType) as Page;
        page.bindingContext = item;

        await Navigation.PushAsync(page);

        // Manually deselect item.
        ItemsListView.SelectedItem = null;


    }

I tried using the overrides of the createinstance method but then I get an error in the constructor of the new page.

I'm trying then to use the bindigContext but I can not get it ..

public partial class ItemDetailPage : ContentPage
{
ItemDetailViewModel viewModel;

    public ItemDetailPage(ItemDetailViewModel model)
    {
        InitializeComponent();

        BindingContext = this.viewModel = (model);
    }

    public ItemDetailPage()
    {
        InitializeComponent();
        BindingContext = ????;
    }
}

How should I do?
Thanks so much.

How to read certificate installing through MDM in iOS

$
0
0

Hi,

How to read certificate installing with the iOS application through MDM. This is a certificate which will be pushed with the application from MDM. How to import this certificate into the application to send to server for authentication.

Thanks in advance

Hide drawer icon in master detail page

$
0
0

I have a master detail page an in certain scenario I want to hide the drawer icon. I know that I can disable it by setting IsGestureEnabled to false but how can I hide it? I guess I need to implement a custom renderer but I am not sure how to hide the icon in the renderer.

How to know if a web image load completed ?

$
0
0

loading a image from web by using UriImageSource for image's Source property.

I can get the event that Image isLoading property changed to false, but I can't find any way to know if the image loaded success???(such as network problem leads image can't download)

I need replace the web image with another local image, how can I solve it correctly??


Facebook blocking deep link?

$
0
0

I just implemented deep linking in our app and clicking an URL seems to work.

I then tried to share a link on Facebook Messenger and when clicking the URL it opens the in-app browser and shows our website.
When reading different sites I understand why Facebook are trying to prevent us from leaving their environment (earning money on ads), but it really breaks the user experience when people tries to see shared content from our app.

A couple of questions:
1. Anyone having an idea how to "break out" of the Facebook in-app browser? (it looks like a user can click the "options" button and manually choose to open the app. but I think it's hard to find for the user if you do not know it's there)
2. Anyone having experiences if this is an issue for you users?
3. How do you handle this?

How can I create a .NET Standard 2.0 Xamarin project in Visual Studio 2017 (not a PCL)

$
0
0

Can't find any useful documentation on how to do this, when creating a project using Visual Studio it creates it as a PCL, is there any documentation on either creating a Xamarin .NET Standard project or converting an existing project from PCL to .NET Standard library?

Thanks in advance,
Andrew

doubt about new project in the same solution

$
0
0

I have a solution with some projects, as droid, ios and more. If i need other projet to create a DLL. If my project is Web API, MVC or Web Forms i create a new ClassLibrary Project(Windows Form or Classic Windows). But i have a new project Xamarin.Forms and in this project i need to add a new project to create a Dll. What kind type of project i add? ClassLibrary form Windows Form or Classic Windows or ClassLibrary(Xamarin.Forms)? This project is to create a DLL only. What kind do i add?

Xamarin.Forms shared project - runtime localization

$
0
0

Hi all,

I am working on the Xamarin.Forms project (shared) and I want to implement localization in the application. User should be able to switch from one language to another and be able to see change right away without restarting the application.

I was investigating the solutions on this and other forums and I didn't find any reliable solution.

Is there any sample project which shows how to do this or can someone post the steps I need to do in order to do this?

Thanks in advance!

Hide stack layout on click of button

$
0
0

Hi I am trying to hide a stacklayout on click of button in my stack layout but it keeps showing.
I am trying to use view model to do this.

XAML:-




<Grid.RowDefinitions>





</Grid.RowDefinitions>
<Grid.ColumnDefinitions>


</Grid.ColumnDefinitions>

                    <StackLayout BackgroundColor="White" Grid.Column="1" Grid.Row="0" x:Name="LeaveThumbnail" IsVisible="True" Spacing="-6" HeightRequest="300">
                        <Image Source="img_leave_plan.png" VerticalOptions="StartAndExpand"  HorizontalOptions="FillAndExpand"></Image>
                        <Label Text="Leave Plan" VerticalOptions="StartAndExpand" XAlign="Center" FontSize="Medium" FontAttributes="Bold"></Label>
                    </StackLayout>

                </Grid>
            </StackLayout>

    </StackLayout>
    </ScrollView>

ViewModel:-

public class CongratsViewModel : INotifyPropertyChanged
{
HttpClientService clientService = new HttpClientService();
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this,
new PropertyChangedEventArgs(propertyName));
}
}

private bool LeaveThumbnail_ = true;
public bool LeaveThumbnail
{
get
{
return LeaveThumbnail_;
}
set
{
LeaveThumbnail_ = value;
OnPropertyChanged("LeaveThumbnail");
}
}

public async Task NeitherType()
{
await navigateHome.PushAsync(new HomePage());
LeaveThumbnail.IsVisible=false;
}

This is not working.Please help.

Issue with Samsung Note 8 running Android 7.1

$
0
0

My app invokes Call Phone intent. There is no problem with Marshmallow phones previously. But now on Note 8 I tried it for the first time. When I invoke the Call Phone intent I get the following Exception.Message.

Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxx cmp=com.android.server.telecom/.components.UserCallActivity launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } } from ProcessRecord{7dc990c 19695:Dates2Remember_XFAXU.Droid/u0a327} (pid=19695, uid=10327) with revoked permission android.permission.CALL_PHONE

A snip of my app's project properties is attached which shows that the Target version is set to 7.1 and the CALL_PHONE requirement is checked.

I am using dependency service. The dependant Android code is shown below. The following may be noted in this regard:

  1. Though Forms.Context is obsolete, it still works. However I have tried the other ways to set the Context also tried. The relevant code is commented below the Forms.Context usage.
  2. The error occurs at context.StartActivity(intent).

    using Android.Content;
    using Android.Telephony;
    using System;
    using System.Linq;
    using Xamarin.Forms;
    using Uri = Android.Net.Uri;

    [assembly: Dependency(typeof(PhoneDialer.Droid.PhoneDialer))]

    // For this to work ensure .Droid's Project Options -> Build
    // -> Android Application -> Required Permissions -> CallPhone
    // is checked.
    namespace PhoneDialer.Droid
    {
    public class PhoneDialer : IDialer
    {
    //Context context => Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity;

        // Dial the phone
        public bool DialFromDevice(string number, string displayName)
        {
            bool rtn_value = false;
    
            try
            {
                var context = Forms.Context;
                //Context context = Android.App.Application.Context;
                //var context = MyApp.Droid.MainActivity.instance;
    
                if (context != null)
                {
                    var intent = new Intent(Intent.ActionCall);
                    intent.SetData(Uri.Parse("tel:" + number));
    
                    if (IsIntentAvailable(context, intent))
                    {
                        context.StartActivity(intent);
                        rtn_value = true;
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error: {0}", ex.Message);
                rtn_value = false;
            }
    
            return rtn_value;
        }
    
        // Checks if an intent can be handled.
        public static bool IsIntentAvailable(Context context, Intent intent)
        {
            var packageManager = context.PackageManager;
    
            var list = packageManager.QueryIntentServices(intent, 0)
                .Union(packageManager.QueryIntentActivities(intent, 0));
            if (list.Any())
                return true;
    
            TelephonyManager mgr = TelephonyManager.FromContext(context);
            return mgr.PhoneType != PhoneType.None;
        }
    }
    

    }

No issue with even Marshmallow simulator for VS. My Note 8 is still at API 25. It appears the project context is not passed on properly. Am I doing anything wrong?

Note: Unfortunately here if you employ multiple modes of formatting something will not presented correctly as required. Any suggestions to correct it, form myside, are welcome.

package fab.forms.2.1.1 was restored using '.net framwork,version=v4.6.1'.

$
0
0

package fab.forms.2.1.1 was restored using '.net framwork,version=v4.6.1' instead of the project target framwork=v2.0'.the package may not be fully compatible with your project.


How can I have multiple Background Triggers for UWP in Xamarin Forms?

$
0
0

Hi. The app I am working on runs in Droid and iOS. Now I have been tasked with adding in UWP. There are three times when I need to start a long running task in the background. And each time I need to call a different task (upload pictures, download pictures, transfer data). My experience indicates that I can only have one background trigger. If I have more I get errors.

Aside from investigating in my app, I took the UWP sample at "Windows-universal-samples-master\Samples\BackgroundTask" and duplicated Scenario5_ApplicationTriggerTask and called it Scenario5B_ApplicationTriggerTask. I also performed similar changes wherever required to all the variables.

When I have registered Scenario5_ApplicationTriggerTask and then go to register Scenario5B_ApplicationTriggerTask, at this line:
BackgroundTaskRegistration task = builder.Register();
I get the following exception:
$exception {System.Exception: Cannot create a file when that file already exists. (Exception from HRESULT: 0x800700B7) at Windows.ApplicationModel.Background.BackgroundTaskBuilder.Register() at SDKTemplate.BackgroundTaskSample.RegisterBackgroundTask(String taskEntryPoint, String name, IBackgroundTrigger trigger, IBackgroundCondition condition, BackgroundTaskRegistrationGroup group) at SDKTemplate.ApplicationTriggerTaskB.RegisterBackgroundTask(Object sender, RoutedEventArgs e)} System.Exception

How have other people handled this case? What might I be missing?

One plan is to set a global variable or a value in SQLite, which gets accessed from the background and used as an indicator for which task to do. That just doesn't smell right.

Thanks for any insight.

How to handle Click event Stacklayout TapGesture. i have defined but never call.

$
0
0

Hello,

I have defined TapGesture on StackLayout but never call it.



<Grid.RowDefinitions>


</Grid.RowDefinitions>
<Grid.ColumnDefinitions>


</Grid.ColumnDefinitions>


<dashbut:dashButton.GestureRecognizers>

</dashbut:dashButton.GestureRecognizers>


<dashbut:dashButton.GestureRecognizers>

</dashbut:dashButton.GestureRecognizers>




Behind. cs file

        MasterDetailPage1 mas = App.Current.MainPage as MasterDetailPage1;
        (mas.Master as MasterDetailPage1Master).ListView.SelectedItem = null;
        mas.Detail = new NavigationPage(new Pages.CropWisePrice());
        //Detail = new NavigationPage(page)
        //MasterPage.ListView.SelectedItem = item
    }

    private async void TapGestureRecognizer_Tapped_1(object sender, EventArgs e)
    {
        MasterDetailPage1 mas = App.Current.MainPage as MasterDetailPage1;
        (mas.Master as MasterDetailPage1Master).ListView.SelectedItem = null;
        mas.Detail = new NavigationPage(new Pages.MarketWisePrice());
    }

------------dashbut:dashbutton View----------------|

<!--

    <Label x:Name="SwitchboardLabel" 
           HorizontalOptions="Center"
           Text="{Binding Label}"
           TextColor="#3A444D" />-->
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="60"></RowDefinition>
            <RowDefinition Height="60"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Image x:Name="SwitchboardIcon" HeightRequest="200" Grid.Row="0" Grid.RowSpan="2" HorizontalOptions="Center" 
           VerticalOptions="Center" Source="{Binding Icon}" />
        <Label x:Name="SwitchboardLabel" Grid.Row="2" Margin="0,0,0,10" FontSize="15" FontAttributes="Bold" TextColor="White" VerticalOptions="EndAndExpand"
           HorizontalOptions="Center" Text="{Binding Label}"/>
    </Grid>
</StackLayout>

....behind .cs code..

public partial class dashButton : ContentView
{
public dashButton ()
{
InitializeComponent ();
}

    public ImageSource Icon
    {
        get { return SwitchboardIcon.Source; }
        set { SwitchboardIcon.Source = value; }
    }

    public string Label
    {
        get { return SwitchboardLabel.Text; }
        set { SwitchboardLabel.Text = value; }
    }
}

Xaml not working for image WidthRequest/HeightRequest

$
0
0

I am using an "ExtendedImage" object that gives more functionality to Xamarin's Image class. However I can't set the size of the image based on the platform in xaml. Here is my code:

<customRenderers:ExtendedImage>

    <customRenderers:ExtendedImage.HeightRequest>
        <OnPlatform x:TypeArguments="Double"
            Android="150" />
    </customRenderers:ExtendedImage.HeightRequest>
    <customRenderers:ExtendedImage.WidthRequest>
        <OnPlatform x:TypeArguments="Double"
             Android="150" />
    </customRenderers:ExtendedImage.WidthRequest>

</customRenderers:ExtendedImage>

It gives an error, saying XAML Parse Error: Type Double not found in xmlns.

But the following code works:

<customRenderers:ExtendedImage WidthRequest="150" HeightRequest="150">
</customRenderers:ExtendedImage>

What is causing it to fail when I try to set it in the OnPlatform tags?

MVVM Really Necessary?

$
0
0

I'd like to start a (non-religious) discussion about whether the benefits of MVVM outweigh the hassle when your phone app is (mostly) just displaying data.

I recently worked on a project in which the user moved from page to page making selections and being shown either a new list of options or being shown data, but there was virtually no business logic involved; all the logic was on the server.

Putting everything in the VM became a royal pain because I had to manage navigation and alert boxes and I ended up using the message center extensively. I didn't reap the benefit of Unit Tests because, as noted, there was virtually no logic to test.

Do you resort to code behind in these cases, and if not, why not?

I know this raises hackles, but I'm not advocating either way; I'm just opening a discussion.

Thanks

How can I databind an image using XAML?

$
0
0

How can I databind an image using XAML?

Specifically, I have a stream object that I would like to convert into an image.

However, I just cannot find a basic example of how to do this.

  1. What does the viewmodel property look like?

    • Do I use an ImageSource?

    • Do I need a value converter?

  2. What does the XAML look like?

Viewing all 58056 articles
Browse latest View live


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