I am trying to add a custom font (or actually fonts) to my Xamarin.Forms app. In my case, it is the Arial font. I have the *.ttf files for the regular, bold, italic, and bold italic variations, and want to create a font family for them as described at:
https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/resources-in-android/fonts
I have placed the files in the Assets folder of my Android project, and I am able to use them individually using the syntax such as FontFamily="arial.ttf#Arial". However, I am somewhat confused as to exactly how to create & use the *.xml file that includes the variations. The sample xml file does not have the font names or files anywhere in it, and I am not sure how to use the xml file after creating it. Can somebody help me? Thanks.
Creating a FontFamily for Xamarin.Forms & Android
How to get audio file locations?
I am trying to get locations of audio files in Xamarin.Forms. I am currently using resources to play audio file, I put there myself, but want to search the phone for these files and save in a List with its locations?
Firebase-How to log exceptions in xamarin.iOS
Hello,
I am implementing Firebase Crashlytics in xamarin forms.I want to log exceptions occurred in try/catch block to firebase.
I am using below line of code to track exception in xamarin android which are reflected as Non-fatal error on firebase portal (Which is achieved).
Android native code-
public void TrackException(Exception exception)
{
Crashlytics.Crashlytics.LogException(Java.Lang.Throwable.FromException(exception));
}
I am using dependency service to call above code in xamarin forms PCL project.
try
{
}
catch(Exception ex)
{
DependencyService.Get().TrackException(ex);
}
Similarly for xamarin.iOS I have method Crashlytics.SharedInstance.RecordError(objNSError);
How can I convert Exception to NSError object in xamarin?
Thanks,
Payal
Handle focus on entry in custom made autocomplete
I have made a autocomplete control - but are not completely happy with how the unfocus of the entry happens
The actual autocomplete consists of a scrollview. Slow dragging inside the ScrollView works, but swipe/swipedragging more aggressively like you would do in a ListView - makes the Entry
lose focus. The Autocomplete then closes as I have programmed it to be.
Is there some way I could manually handle the deselection of the entry when the user is interacting with the autocomplete (inside the scrollview)?
webview open new blank page in browser
public MainPage()
{
Title = "XXXXXX";
var source = new UrlWebViewSource();
source.Url = "http://XXXXXXXXX/student/studentlogin.aspx";
var webView = new WebView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Source = source
};
webView.Navigating += (s, e) =>
{
if (e.Url.Contains("FeeReceipt.aspx"))
{
try
{
var uri = new Uri(e.Url);
Device.OpenUri(uri);
}
catch (Exception)
{
}
e.Cancel = true;
}
};
webView.Navigated += (object sender, WebNavigatedEventArgs e) => {
System.Diagnostics.Debug.WriteLine("Done");
};
Content = new ContentView {
Content = new StackLayout {
Children = {
webView
}
}
};
}
Tool bar menu item xamarin forms
Thanks
Advice to handle html files in external storage
Hi guys, i'm a xamarin newbie. I have developed a simple Forms app to display some particular html files (by webview). To store the files i've used embedded resource. Now i need to implement a mechanism to updates of that files...so i've developed an asp net mvc web api. When i call it returns to me a zipfile with updated contents (they must be stored in the sd card). In your opinion, what is the best way to handle a lot of html files stored in the sd storage? Must i copy them to Asset (or assets are write only..?) to visualize them?
Thank you very much for your advices, i'm a little bit confused.
Toolbar menu item customization
Icon =Accepting only drawable image.
Requirement
Icon = load image url or font awesome icon.
How to download a file from url in xamarin form
I am trying to download a file from url and I am not using plugin . can any one please help me how to download a file from url.
Linking Assemblies leads to Binding Property not updating
In my Xamarin.Forms app, there is an issue when creating the Release build:
In MyView.xaml, I have a Label with a Text binding:
<Label Text="{Binding ProgressInfo.Message, Mode=TwoWay}" />
In MyViewModel.cs I have the Property:
private (double Value, string Message) progressInfo;
public ( double TotalProgressInPct, string Message) ProgressInfo { get => progressInfo; set => SetProperty(ref progressInfo, value); }
where SetProperty is from a different assembly (MvvmHelpers)
The update of the text label works fine with No Linking, but not with Link SDK Assemblies, where the Label text does not update. All other Labels are updated just fine.
For some reason, the tuple character of the property does not work nice with the Linker? Thankful for any hints!
External ResourceDictionary in several projects
Hey Guys,
I'm trying to include my resource dictionary in several android applications because every app should have the same background, labels .. you know what I mean.
What have I tried?
I've had tested if my style and the application work together in the same project. I've created a external .net standardlibrary to centralize it.
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Color x:Key="PrimaryText">#FAFAFA</Color>
<Color x:Key="SecondaryText">#F5F5F5</Color>
<Color x:Key="HintText">#80FFFFFF</Color>
I've add the reference (Styles.dll) to my application
When I want to add my style to (e.g.) my labels I use "StaticResource" and "DynamicResource". When I use StaticResource and run the program it throws "Xamarin.Forms.Xaml.XamlParseException: 'Position 40:20. StaticResource not found for key ErrorTextColor'". When I use DynamicResource the application starts but it doesn't take the style.
In app.xaml I've add the namespace and assembly
<?xml version="1.0" encoding="utf-8" ?>
<prism:PrismApplication xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:theme="clr-namespace:Styles;assembly=Styles"
xmlns:prism="clr-namespace:Prism.DryIoc;assembly=Prism.DryIoc.Forms"
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<theme:BlackStyleDictionary/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</prism:PrismApplication>
After I googled a lot I found out that I actually can use "mergedDictionary" to include it to my project but that doesn't work - also "ResourceDictionary Source="...Path" doesn't work for me.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<theme:BlackStyleDictionary/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
My App.xaml has "InitializeComponent();" and I tried to build my library as embedded resource, resource and content.
I spent much time to google but don't find an answer so I need you to resolve it.
What works?
As I mentioned above when I had my style.xaml in my current app everything works fine, so there is no problem with the resourcedirectionary.
If you need more information for the solution feel free to ask for it.
Many thanks in advance,
Esorana
Can I prevent a TapGestureRecognizer from swallowing touches?
I have a custom ViewCell with an Entry in it. I'm using a TapGestureRecognizer in the cell so that I can give focus to the Entry regardless of where the user taps in the cell. In my custom ViewCells without TapGestureRecognizers, I'm able to manage the pressed effect on the cells (adjusting their background color) by using a custom renderer. Unfortunately, the tap effects aren't handled by the custom renderer if the TapGestureRecognizer processes the touch. This leaves me without any sort of pressed effect highlighting for tapping the cell. Is there some way I can prevent the Xamarin TapGestureRecognizer from swallowing touches?
Xamarin Forms Webview doesn't show the tradingview widget.
Hi all,
I use a widget from tradingview site. I would like to make this implementation using xamarin forms webview. However i can't make it works. It just doesn't appear the widget at all.
The same piece of code woks correctly on a browser.
In the html code there is a script tag which the source file is from external resources(from their site).
So i would like to ask if the webview can load javascript resources from the web.
Any help will be appreciated.
Thanks in advance!
I would copy&paste the code but the forum doesn't allow me because every time i paste the code a captcha appear to check if i am human . When i click the check button the whole text disappeared. I try to post code like an answer of this question.
How can I connect to our internal IIS server from VS debug session?
I've written and deployed an asp.net core 3 web api REST service to our server on our network, which is hosted in IIS, and sending HTTP requests to the service works using Postman. Now I am writing a Xamarin app which needs to connect to this service. All this will be from within our network, so the server is referenced by name and its IP address is always an internal one. When debugging the app in Visual Studio, I cannot reach the server.
The Xamarin project is UWP and Android, and so far I've only been testing on UWP. I can get a response from google.com, but not from our internal server either by name or internal IP address.
[Grouped Listview]: Is it possible to retrieve the group header when item selected?
Hi,
I would like to retrieve the header string (GroupDisplayBinding) when I select an item in the grouped listview.
Is this possible?
Thanks in advance!
Shell Content page destruction
Using 4.3, say I have 3 tab items, each of them having 2 ShellContent items.
I am using ContentTemplate to only create the times when I click on them.
Now since we have quite a large application we would like to destroy the Tab Items Shell Contents if they select another Tab, is this possible? In general how can we destroy a Content page once it gets the disappear event?
thanks
Hi guys ! Someone knows how to click on a collectionView to display content with mvvm
Help me please
google drive in xamarin forms
Can ayone help hot to integrate google drive in xamarin forms
[Android] Enabling scrolling for a WebView inside a ScrollView
I had this problem a while ago and I didn't found a complete solution for this here in the forum so I'm posting a solution using a Custom Renderer that is very simple and worked very well for me and I bet that it should work for other components too. (Eg: ListView inside ScrollView, nested ScrollViews).
I hope others find it useful too.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Droid.CustomRenderers;
[assembly: ExportRenderer(typeof(WebView), typeof(ScrollableWebViewRendererAndroid))]
namespace Droid.CustomRenderers
{
public class ScrollableWebViewRendererAndroid : WebViewRenderer
{
public ScrollableWebViewRendererAndroid()
{
System.Diagnostics.Debug.WriteLine("ScrollableWebViewRendererAndroid()");
}
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
Control.Touch -= Control_Touch;
}
if (e.NewElement != null)
{
Control.Touch += Control_Touch;
}
}
void Control_Touch(object sender, Android.Views.View.TouchEventArgs e)
{
// Executing this will prevent the Scrolling to be intercepted by parent views
switch (e.Event.Action)
{
case MotionEventActions.Down:
Control.Parent.RequestDisallowInterceptTouchEvent(true);
break;
case MotionEventActions.Up:
Control.Parent.RequestDisallowInterceptTouchEvent(false);
break;
}
// Calling this will allow the scrolling event to be executed in the WebView
Control.OnTouchEvent(e.Event);
}
}
}
Error Building iOS project on Xamarin Forms
Hi,
I am trying to build my iOS in my Xamarin Forms using Visual Studio for Windows but getting this error..
Kindly help...
Thanks,
Jassim