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

NavigationPage.TitleView does not work

$
0
0

Based on this article and multiple posts here, I attempted to add a custom title bar to my NavigationPage

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Forms.MainPage"
             Title="MyMainPage">
  <NavigationPage.TitleView>
    <Label Text="Test"/>
  </NavigationPage.TitleView>
   ...
</ContentPage>

App.cs

public App()
{
    ...
    MainPage = new NavigationPage(new MainPage())
    {
        BarTextColor = Color.White,
        BarBackgroundColor = Color.Black
    };
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.MyCompany" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
    <application android:label="MyCompany.Android" android:icon="@mipmap/icon"></application>
</manifest>

But it does not display. The default app Titlebar, with the app-icon and text "MyMainPage", still displays.
(Xamarin.Forms v4.6.0.967, but I had the same issue with v4.4)

What am I doing wrong?


How to integrate Video Calls into Xamarin Forms App.

apk reinstall error "App not Install" after adding New Packages Micocharts and Microcharts.Forms.

$
0
0

I have created a sample app and signed an apk using adhoc which is successfully installed on my phone. After adding one page with microcharts i have increased the version of app and created new apk with adhoc but while installing installation failed with message "App not installed". I need to know what am i missing or any permission required.

Thanks in advance.

TextChange occur before placeholder disappears from Entry?

$
0
0

I am adding a custom clear button over my entry using absolute layout. Everything is working - but on iPhone 11 the X clear button renders over the placeholder text for short moment. Isen't the TextChanged event supposed to be triggered after text is added - meaning the placeholder should be gone at that point?

expander.ForceUpdateSize is getting crashed

$
0
0

I have Label which needs to be expanded and collapsed but after few times, It is throwing an exception.

any help is appreciated.

AdMob in ios works fine, android does not

$
0
0

With both test and my ids ads show fine in ios. In android they do not with either. Tried with xamarin.firebase.ads and xamarin.googleplayservies.ads and neither works and throws no errors. How do I debug?

Code:

shared AdBanner.cs

using System;
using Xamarin.Forms;

namespace AdMob.CustomRenders
{
public class AdBanner : View
{
public enum Sizes
{
Standardbanner, LargeBanner, MediumRectangle, FullBanner, Leaderboard, SmartBannerPortrait
}
public Sizes Size
{
get; set;
}
public AdBanner()
{
this.BackgroundColor = Color.Accent;
}
}
}

snippet of xaml
<?xml version="1.0" encoding="UTF-8"?>

<ContentPage.Content>


Android manifest (XXS IN ID TO HIDE REAL ID

<?xml version="1.0" encoding="utf-8"?>



<application android:label="Scent Work Log" android:icon="@drawable/ic_launcher_round">
    <provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
    </provider>
 <meta-data
         android:name="com.google.android.gms.ads.APPLICATION_ID"
         android:value="ca-app-pub-87XXXX5634776~7430XXX315"/>
              <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
</application>

AdBanner_droid.cs

using System;
using AdMob;
using Android.Gms.Ads;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using AdMob.CustomRenders;
using AdMob.Droid.CustomRenders;
using Android.Content;

[assembly: ExportRenderer(typeof(AdBanner), typeof(AdBanner_Droid))]
namespace AdMob.Droid.CustomRenders
{
public class AdBanner_Droid : ViewRenderer
{
Context context;
public AdBanner_Droid(Context _context) : base(_context)
{
context = _context;
}
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
var adView = new AdView(Context);
switch ((Element as AdBanner).Size)
{
case AdBanner.Sizes.Standardbanner:
adView.AdSize = AdSize.Banner;
break;
case AdBanner.Sizes.LargeBanner:
adView.AdSize = AdSize.LargeBanner;
break;
case AdBanner.Sizes.MediumRectangle:
adView.AdSize = AdSize.MediumRectangle;
break;
case AdBanner.Sizes.FullBanner:
adView.AdSize = AdSize.FullBanner;
break;
case AdBanner.Sizes.Leaderboard:
adView.AdSize = AdSize.Leaderboard;
break;
case AdBanner.Sizes.SmartBannerPortrait:
adView.AdSize = AdSize.SmartBanner;
break;
default:
adView.AdSize = AdSize.Banner;
break;
}

            // TODO: change this id to your admob id  
            adView.AdUnitId = "ca-app-pub-8767021289934776/6619715915";
            var requestbuilder = new AdRequest.Builder();
            adView.LoadAd(requestbuilder.Build());
            SetNativeControl(adView);

        }
    }
}

}

snippet of main activity

protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;

        base.SetTheme(Resource.Style.MainTheme);

        MobileAds.Initialize(ApplicationContext, "ca-app-pub-8767021289934776~7430520115");

        UserDialogs.Init(this);

Can't edit background color of NavigationPage.TitleView

$
0
0

Following the advice here, I'm using

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity

then based on this link I had to add to AndroidManifest.xml

<application android:theme="@style/MainTheme" ...>

Now I can get NavigationPage.TitleView to display, but I can't get the background color to change!


I tried the suggestions here, but neither changing BarBackgroundColor (which worked when using FormsApplicationActivity) nor changing colorPrimary worked.

styles.xml

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <style name="MainTheme" parent="MainTheme.Base"/>
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionModeOverlay">true</item>
    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
  </style>
  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog"/>
</resources>

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="launcher_background">#EF4957</color>
    <color name="colorPrimary">#5C7ABA</color>
    <color name="colorPrimaryDark">#5C7ABA</color>
    <color name="colorAccent">#CE404C</color>
</resources>

MainPage.xaml

  <NavigationPage.TitleView>
    <StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" BackgroundColor="Gray">
      <Label Text="Test"/>
    </StackLayout>
  </NavigationPage.TitleView>
  <ContentPage.ToolbarItems>
    <ToolbarItem Text="Example Item"
                 IconImageSource="baseline_settings_black_24.png"
                 Order="Primary"
                 Priority="0"
                 Clicked="OnSettingsClicked"/>
  </ContentPage.ToolbarItems>
  ...

So how do I change the background color?

how to set flyout selecteditem color to gradient in xamarin forms shell

$
0
0

Hi,

is there anyway to set the selected flyout item color to gradient color in xamarin forms shell?


How i can paginate a List in Xamarin forms?

$
0
0

Hi everyone the problem is i have a lot of data in a list view in a page and it make that the aplication load slowsly the list view my question is how i can paginate the list view in the page ?

problem with xamarin ios

$
0
0

when i call a web service shiw this message :
MonoTouch does not support dynamic proxy code generation. Override this method or its caller to return specific client proxy instance,

in Android has no problem,

I am using a client class generated with SvcUtil.exe, the web service is WFC,

How to solve -"cannot resolve assembly: Xamarin.Forms.Platform.WinRT" ?

$
0
0

I am upgrading .Net Framework to .Net Standard.But when i am creating a blank UWP Project in My existing .Net Standard Project ,I am getting the following exception.
[cannot resolve assembly: Xamarin.Forms.Platform.WinRT, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null.' ]
Any suggestion please?

firebase notification IOS

Pull the navigation drawer in code

$
0
0

I am looking for a way that way that in a certain interception I should be able pull the navigation drawer from the side in code.

How to open OneNote from Xamarin.Forms

$
0
0

In my classic UWP app, I can open a goto and open a OneNote Notebook using the following code.

string Globals.CurrentNotebookId ="0-50FCFxxxxxxxx68D!5xxx4"
string tempUri = "";
string[] tempUriArray = Globals.CurrentNotebookId.Split('-');

        try
            {
                //Open in default browser:
                tempUri = "https://onedrive.live.com/redir?resid=" + tempUriArray[1].ToString();
                var oneNoteUri = new Uri(tempUri);
                var launched = await Windows.System.Launcher.LaunchUriAsync(oneNoteUri);
            }
            catch
            {
                //// Open with Edge:
                ///
                tempUri = "microsoft-edge:https://onedrive.live.com/redir?resid=" + tempUriArray[1].ToString();
                var oneNoteUri = new Uri(tempUri);
                var launched = await Windows.System.Launcher.LaunchUriAsync(oneNoteUri);
            }

How can I do the same thing with Xamarin Forms for an Android project and UWP project?

Essentials Geocoding

$
0
0

Hello!

I am trying to find out what the limits are for Xamarin Essentials Geocoding. I've been googling for a while now and can't find anything =/

Looking for answer to:

  • How many requests per second/minute?
  • Is there a daily/monthly limit?

Thanks!

Daniel


How to make second bottom toolbar with buttons

$
0
0

I need to create bottom toolbar with buttons. It must be capable of such things as:

  • contain imaged buttons with occasional badges.
  • some buttons must act like commands (e.g. display alert message), others open random pages.
  • buttons added dynamically at runtime.
  • target platforms: IOS, Droid, UWP
  • toolbar can be hidden/shown at runtime

I tried few approaches, all with subjective restrictions:

TabbedPage

  • requires existent content pages.
  • cannot receive content of another page, not in tabbedpage list
  • buttons cannot act as commands, couldn't find a way to intercept "before change" event and stop it if neccessary.
  • no way to unselect button. One is always selected. This one is the most frustrating, because I thought about create a tabbed page in the bottom of main page with empty pages and zero content height.

Native bottom bar
Have examples for Droid
(docs.microsoft.com/en-us/xamarin/android/user-interface/controls/tool-bar/adding-a-second-toolbar)
and IOS
(docs.microsoft.com/en-us/xamarin/ios/user-interface/controls/creating-tabbed-applications)

  • cannot dynamically add/remove buttons
  • cannot dynamically add/remove toolbar
  • not universal (need to create xml android forms and weld it into page)

Hardcore manual mimic toolbar with Grids/Boxes

  • have to support all styles/effects to match othet Material-design/ios style

After couple days I stopped at variant three with drawing toolbar with grids, imagebuttons and circles.

The question is more of asking for advice. Is there a way to achive dynamic bottom toolbar with standard controls?

Thank you in advance.

Swipe programmaticallyitem in list view

$
0
0

Hi,

How do I swipe item programmatically in list view ? For example : If I have an item with a swipe menu instead of swipping with touch gesture I want to swipe the item programmatically when clicking on a button display on my cell items. I could add a command for my button but How can I swipe the specific item where the user is clicking on the button.

Custom view for showing any type of doc/image

$
0
0

Hi Geeks,

I tried to make a custom view for showing any type of document, PDF, image, or doc.

Most of the answers are Webview, but it is not giving me the desired result. Currently, I am opening my doc depending on the extension and if the supported app is available then I am opening the file.

    public ErrorCodes OpenFile(string filePath)
    {


            var context = Android.App.Application.Context;
            var bytes = File.ReadAllBytes(filePath);
            Java.IO.File file = new Java.IO.File(filePath);
            file.SetReadable(true);
            string application = string.Empty;
            string extension = Path.GetExtension(filePath);
            string mimeType = MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension);

            switch (extension.ToLower())
            {
                case ".txt":
                    application = "text/plain";
                    break;
                case ".doc":
                case ".docx":
                    application = "application/msword";
                    break;
                case ".pdf":
                    application = "application/pdf";
                    break;
                case ".xls":
                case ".xlsx":
                    application = "application/vnd.ms-excel";
                    break;
                case ".jpg":
                case ".jpeg":
                case ".png":
                    application = "image/jpeg";
                    break;
                default:
                    application = "*/*";
                    break;
            }

            Android.Net.Uri uri = Android.Net.Uri.FromFile(file);
            Intent intent = new Intent(Intent.ActionView);
            intent.SetDataAndType(uri, application);
            intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);
            Android.Net.Uri path = FileProvider.GetUriForFile(context, "com.app.mobile_new.app.fileprovider", file);
            intent.SetDataAndType(path, mimeType);
            intent.AddFlags(ActivityFlags.GrantReadUriPermission);
            context.StartActivity(intent);
            errorCodes = ErrorCodes.Succes;
        }

What I am trying to achieve is file should not depend on the installed software rather I can view them in my Custom view.

Most of the solution which is available only for PDF files.

Please let me know if this is possible in xamarin forms.

Thanks

Lock screen UI

$
0
0

Hi guys, I'm working on music music player app using MediaManager .
I have this 2 screenshots which the first is my current situation and the second one is the desired results.
Using Android emulator for this example,
Current:

Desired result:

Where do I control the data that displayed over the lockscreen? artist, title, image and other functions?

ListView: Binding Commands using ItemTemplateSelector

$
0
0

It's my curse. To demand too much and know too little...

For my ListView I use an ItemTemplateSelector class to decide which ItemTemplate/ViewCell to use. The ViewCells are located in separate files.

How can I bind a Button in my ItemTemplate/ViewCell to a Command in my MainViewModel ?
When it is a regular ListViewItem I can do it like this:

<Button Text="Test" Command="{Binding BindingContext.TestCommand, Source={x:Reference viewModel}}"/>

Is there any chance to get to the Parent Binding.Context within my ItemTemplate, best with MVVM ?

Viewing all 79144 articles
Browse latest View live


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