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

how to load custom fonts in webview in xamarin forms uwp project

$
0
0

Im having problem to load and apply custom fonts in html data loaded into a webview component in a xamarin forms UWP project.Since the fonts doesnt get loaded, the proper font is not applied to the text in the html.

Im creating a xamarin forms application in which i use a webview view to display html data from a book. The data is text from a book and uses some custom fonts like Alvi Nastaleeq to style the text. The fonts are applied in the IOS and Android versions using font-face rule but it doesnt work in UWP. The fonts are in the Assets/Fonts folder in the UWP project.

I have tried using font-face rule in UWP with correct URI-scheme ms-appx-web:// and it doesnt work. I have also gone through the suggestion in the following post: https://blogs.msdn.microsoft.com/wsdevsol/2012/10/23/about-webview-and-fonts/ and doesnt work either

I have tried loading both .woff and .ttf fonts but it doesnt work.

this is what i have in the header of the html:

                // this one was a try for UWP.. not working..
            @font-face {
            font-family: 'Alvi Nastaleeq';
            src: url('ms-appx-web:///Assets/Fonts/Alvi Nastaleeq.ttf');
            } 

                 // theese are for IOS and Android and works..
           @font-face { 
            font-family: Alvi Nastaleeq;
            src: url('Fonts/Alvi Nastaleeq.ttf') 
                }
            @font-face { 
            font-family: Aslam;
            src: url('Fonts/Aslam.ttf') 
                }
            @font-face { 
            font-family: Al Qalam Quran Majeed;
            src: url('Fonts/Al Qalam Quran Majeed.ttf') 
                }
            @font-face { 
            font-family: Amiri-Bold;
            src: url('Fonts/Amiri-Bold.ttf') 
                }
       </style>

I want to get the fonts applied to the html data loaded into the webview view in the UWP version of my xamarin forms application.


XLS0507 Code Error

$
0
0

Error message : My (xyz.xaml) page is not usable as an object element because it is not public or does not define a public parameterless constructor or a type converter.

set custom font in webview

$
0
0

I want to set my own custom font in webview.

WebView Description = new WebView(this.Context); WebSettings settings = Description.Settings; settings.FixedFontFamily = "DIN-Condensed-Bold.ttf";

I have added my Font called DIN-Condensed-Bold.ttf in Assets/fonts folder, but I don`t see the effect.
Is it build action problem? How can I implement it?

ObservableCollection where clause eror

QueryProperty set being called after OnAppearing

$
0
0

Hello, I have a Shell application and am calling a page using "await Shell.Current.GoToAsync("//page?Id=1");" I have a string property and defined the QueryProperty attribute on my Page class. I have code in the OnAppearing that uses the id to get data from the database. However, the property setter isn't being called until after the OnAppearing event executes so the value is incorrect. Any ideas what I could be doing wrong?

Error while loading assemblies : Microsoft.AppCenter.Analytics.iOS.Bindings.dll

$
0
0

I last successfully built an app last week (Jan 30), when I go to build it today after making no code changes I get the above error - argh!

I dev in VS2019 on Windows 10 and use 'macincloud' for building.

I also seem to be getting a 'hot reload' error when loading the project which seems related somehow.

I've tried cleaning/rebuilding the project but it made no difference. I've also tried different linker settings (originally 'off'), no joy. Removing the AppCenter packages and related code dose allow the app to build successfully and also 'fixes' the hot reload errors. Naturally, I would really prefer to keep the AppCenter features.

Any suggestions?

Thanks

Chris

Full error :

Error Error while loading assemblies: /Users/user12345/Library/Caches/Xamarin/mtbs/builds/**someproject**.iOS/869cf9694adb03b8dc80fafefd154bd1/bin/iPhone/Debug/Microsoft.AppCenter.Analytics.iOS.Bindings.dll **someproject**.iOS C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 842

Visual Studio info :

Microsoft Visual Studio Professional 2019
Version 16.4.4
VisualStudio.16.Release/16.4.4+29728.190
Microsoft .NET Framework
Version 4.8.03752
Xamarin 16.4.000.309 (d16-4@1d551f9)
Xamarin.iOS and Xamarin.Mac SDK 13.10.0.17 (5f802ef)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

How to use both GestureRecognizers and Effects in Xamarin Forms at the same time?

$
0
0

I am creating a custom control. I want to change the Background Color When Touched using Custom Effects in the Native Code and also handle the TapGesture Event in the Event Handler in the backend code. But When I do this only one of these two is happening (ie. When I define Grid.GestureRecognizer first and then Grid.Effect then Grid.Effect is only getting executed and vice versa). As both are dependent on OnTouch Events one is getting overridden by the other. How to tackle this.

In Xaml file:
<.Grid >
<Grid.GestureRecognizers>
<TapGestureRecognizerTapped="OnTapGestureRecognizerTapped"/>
</Grid.GestureRecognizers>
<Grid.Effects>

</Grid.Effects>
//OtherCode
</.Grid>

In Backend Code:
event EventHandler Click;

             void OnTapGestureRecognizerTapped(object sender, EventArgs args)
                    {
                        if (Click != null)
                            Click.Invoke(this, args);
                    }

In Native Code The Effect.cs

            protected override void OnAttached()
            {
                Container.SetOnTouchListener(new MyOnTouchListener());
            }

              public class MyOnTouchListener : Java.Lang.Object, Android.Views.View.IOnTouchListener
                    {
                        public bool OnTouch(Android.Views.View v, MotionEvent e)
                        {
                            switch (e.Action)
                            {
                    }
                       }
                 }

Or is there anyother efficient way of doing this?

Two gesturerecognizer only one receive the tap?

$
0
0
    <Grid>
                            <Grid.GestureRecognizers>
                                <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_2" NumberOfTapsRequired="2"/>
                            </Grid.GestureRecognizers>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Label Text="{Binding Id}" Grid.Column="0"/>
                            <Label Grid.Column="1" CharacterSpacing="5" FormattedText="{Binding FormattedString}"/>
                        </Grid>

in the second Label there maybe a Span with gesturecognizer.and the Grid's TapGestureRecogonizer then can not receive the tap.
If the second Label do not have a gestureRecogonizer then The Grid's TapGestureRecogonizer works.

why?


I want to show a video player in eachcell in Listview in XAMARIN forms. Please suggest me.

$
0
0

Please let me know. Guys, I need some sort of suggestion.

recreating existing app visual using Xamarin.Forms

How to reference ResourceDisctionary element from

$
0
0

Hello Community,
I want to know whether it is possible to reference a resourceDictionary element from another one. Im currently developing an app which I want to change in apperance/color from time to time. Therefore I have to change some main colors but I want to be able to change any specific value, too, without going into the code.
So what I need is something like

<Color x:Key="color1">#ABCDEF</Color>
<Color x:Key="color2">reference to color1</Color>

I want to change color1 and change every associated element but be able to change each individual element, too.

Can you use Experimental features in release mode?

$
0
0

I'm very excited about many of the new controls coming to Xamarin that are currently in experimental state.
Before using the SwipeView in an application, is there any prohibition against using them in a Release build?

Standard caveats of course, not guaranteed or fully vetted - but my application is targeting very specific and defined devices for iOS, Android, and UWP (not going to be released to the general public or go through the app stores) so I will be able to test the application on all the supported devices.

I just don't want to spend the time implementing the SwipeView then discover "oops, you're using an experimental control, we won't build/deploy for you".

Initialize CarouselView in UWP?

$
0
0

Hey,

how can I initialize CarouselView in UWP?
working fine on Android but in UWP the ItemSource is empty.

CarouselView

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
... >   
    <NavigationPage.TitleView>
      ....
    </NavigationPage.TitleView>

    <ContentPage.ToolbarItems>
       ....
    </ContentPage.ToolbarItems>

    <StackLayout Margin="10">
        <CarouselView>
            <CarouselView.ItemsSource>
                <x:Array Type="{x:Type x:String}">
                    <x:String>Baboon</x:String>
                    <x:String>Capuchin Monkey</x:String>
                    <x:String>Blue Monkey</x:String>
                    <x:String>Squirrel Monkey</x:String>
                    <x:String>Golden Lion Tamarin</x:String>
                    <x:String>Howler Monkey</x:String>
                    <x:String>Japanese Macaque</x:String>
                    <x:String>Mandrill</x:String>
                    <x:String>Proboscis Monkey</x:String>
                    <x:String>Red-shanked Douc</x:String>
                    <x:String>Gray-shanked Douc</x:String>
                    <x:String>Golden Snub-nosed Monkey</x:String>
                    <x:String>Black Snub-nosed Monkey</x:String>
                    <x:String>Tonkin Snub-nosed Monkey</x:String>
                    <x:String>Thomas's Langur</x:String>
                    <x:String>Purple-faced Langur</x:String>
                    <x:String>Gelada</x:String>
                </x:Array>
            </CarouselView.ItemsSource>
        </CarouselView>
    </StackLayout>
</ContentPage>

calling from another class

await Navigation.PushAsync(new MyCarouselPage());

App.xaml.cs

          ' Xamarin.Forms.Forms.SetFlags("CarouselView_Experimental");
            Xamarin.Forms.Forms.Init(e);'

Mainactivity.cs

        ' global::Xamarin.Forms.Forms.SetFlags("CarouselView_Experimental");
         global::Xamarin.Forms.Forms.Init(this, savedInstanceState);'

AppDelegate.cs

' global::Xamarin.Forms.Forms.SetFlags("CarouselView_Experimental");
     global::Xamarin.Forms.Forms.Init();' 

UWP

Best regards

fixed footer listview xamarin forms ?

How to use storedprocedures created in sql server in xamarin to display datas in the form of Report.

$
0
0

How to use storedprocedures created in sql server in xamarin to display datas in the form of Report.How to create Reports in Xamarin.
How to connect xamarin app to cloud and take data from it and display it as Reports


Grabbing Website Title is too slow

$
0
0

Hi,

I am using below code to grab website title and I also want later to grab the website photo(s) just like what Fcebook, linkedin and twitter is doing

The problem I facing here that it is too slow and takes very long time to show the title unlike when you do it using facebook or linkedin for example

How can I fix that please?

private async void Button_Clicked(object sender, EventArgs e)
{
    LabelWebsiteURL.Text = EntryURL.Text;

    HttpClient hc = new HttpClient();
    HttpResponseMessage response = await hc.GetAsync(new Uri(LabelWebsiteURL.Text, UriKind.Absolute));
    string source = await response.Content.ReadAsStringAsync();

    string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;

    LabelWebsiteTitle.Text = title;
}

Thanks,
Jassim

Katalon Automation Tool not able to retrieve resource ID for Xamarin.Forms Controls

$
0
0

Hi Team,

We using Xamarin.Forms to develop cross-platform apps.

We are using the Katalon Automation Tool for Mobile App recording and the scripts will be generated automatically for execution and the same can be used for further mobile app testing (if no changes in app).

While running the Xamarin.Forms developed App (Android Platform - APK File), not able to get the Control ID ( Resource-ID or content desc) for all the controls used ( Button, Entry, Picker, Date Picker,Time Picker, Checkbox, Radio button, Autocomplete and Listivew, etc.,).

For that we have tried to provide ID for controls by assigning the property X:Name, AutomationId, x:Uid,AutomationProperties.Name but these are not retrieving in katalon Automation tool.

Kindly help us or advise to have the Resource-ID or content desc in Katalon Automation tool for Xamarin.Forms developed App.

Invalid number of rows in section

$
0
0

I trying to bind a ListView with an ObservableCollection. It works on both Windows Phone and Android but when running it on iOS I get an exception. The message says:

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (130) must be equal to the number of rows contained in that section before the update (0), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).

 public partial class TransfersView : ContentPage
     {
         public TransfersView(TransfersViewModel model)
         {
             InitializeComponent();

             BindingContext = model;  
         }
     }


  <ListView x:Name="Transfers" ItemsSource="{Binding Transfers}">
     <ListView.ItemTemplate>
       <DataTemplate>
         <TextCell Text="{Binding Player}" />
       </DataTemplate>
     </ListView.ItemTemplate>
   </ListView>

Does anyone has a solution?

CultureInfo.CurrentCulture always returns 'en-US' in iOS 11

$
0
0

I've noticed that in iOS 11 the value of System.Globalization.CultureInfo.CurrentCulture always seems to return 'en-US' regardless of the language actually set on device. I never saw this issue with iOS 10 (that is it always returned the language of the device) so I'm not sure if this is a bug or some other change under iOS 11.

Is there a way to combine DynamicResource and IValueConverter

$
0
0

I have some styles that change at runtime, so naturally I am using XAML like this:

<Style x:Key="ThemedFrame" TargetType="Frame">
    <Setter Property="BackgroundColor" Value="{DynamicResource ThemeColorSurfacedp1}" />
    <Setter Property="BorderColor" Value="{DynamicResource ThemeColorSurfacedp24}" />
</Style>

This approach, however, requires I create a variety of resources for all possible combinations of Color elevations (and other things such as opacity).

I'd prefer to do something like this:

<Style x:Key="ThemedFrame" TargetType="Frame">
    <Setter Property="BackgroundColor" Value="{DynamicResource ThemeColorSurface, Elevation=1}" />
    <Setter Property="BorderColor" Value="{DynamicResource ThemeColorSurface, Elevation=24" />
</Style>

I've been trying to work out if it is possible to create a custom markup extension that either works the same way as DynamicResource with additional properties (as per my example), or somehow combine a DynamicResource with a Converter.

Does anyone know if this is even remotely possible?

Viewing all 81910 articles
Browse latest View live


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