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

SVG image is not displaying in android in xamarin.forms

$
0
0

I am trying ti display the SVG image in my xamarin.form application, there are no issues to display the SVG image in iOS but not able to display the same image in the android application.

here is my code to display the svg image
<ContentView.Resources> <ResourceDictionary> <ffimageloadingsvg:SvgImageSourceConverter x:Key="SvgImageSourceConverter"></ffimageloadingsvg:SvgImageSourceConverter> </ResourceDictionary> </ContentView.Resources> <ContentView.Content> <ffimageloadingsvg:SvgCachedImage Source="{Binding SvgFileName, Converter={StaticResource SvgImageSourceConverter}}" Grid.Column="0" WidthRequest="200" HeightRequest="600" ReplaceStringMap="{Binding BodyMapreplceStrings}" /> </ContentView.Content>

And from View Model I am binding the image as following

 public string SvgFileName
        {
            get { return _svgFileName; }
            set
            {
                _svgFileName = value;
                OnPropertyChanged();
            }
        }

and

SvgFileName="Flower.svg";

and given svg image in Resources for iOS and in Resources ->drawable

in MainActivity added following lines
CachedImageRenderer.Init(true);
var ignore = typeof(SvgCachedImage);

Is there anything I am missing?


Is there any way to implement Stripe card widget in the Xamarin.Forms?

Debugging Session issues.

$
0
0

A number of versions ago I started noticing odd debugging to device behaviours, I'm wonder if someone here can shed light on my situation. I'm debugging my Xam Forms PCL project to a Sony Xperia Android device. On the device I use SQLite to store some local data for the app. In the past, no matter how many times I unplug my device and plug it back in - the SQLite data source always persisted between debugging sessions. Recently I've started noticing this data being cleared whenever I unplug and replug in the device... Its frustrating as I have to keep re-entering credentials each time. If I leave the device plugged in it does keep the sqlite details for multiple debug sessions, but once I go for a break - unplug the phone and then re-plug it in - my local data source vanishes?

Furthermore - after initial plug-in and on first debug session - it is taking the Visual Studio 2017 8 minutes....YES 8 MINUTES to start the app... Once it has started this delay shortens drastically, but once I replug it in - its again 8 minutes for the first debug session.... Wasting lots of my time....

Anyone else experienced this? Any suggestions of how to find the cause of the problem also welcomed...

Hover Effect is not working properly on button in Xamarin UWP

$
0
0

I tried to add a hover effect for a button.
Following code shows a custom class created in UWP

[assembly: ResolutionGroupName("MyCompany")]
[assembly: ExportEffect(typeof(FocusEffect), "FocusEffect")]
namespace EffectsSample.UWP
{
class FocusEffect : PlatformEffect
{
protected override void OnAttached()
{
try
{
(Control as Windows.UI.Xaml.Controls.Control).PointerEntered += pointer_Entered;
}
catch (Exception ex)
{
Debug.WriteLine("Cannot set property on attached control. Error: ", ex.Message);
}
}
private void pointer_Entered(object sender, RoutedEventArgs e)
{
(this.Control as Windows.UI.Xaml.Controls.Control).Background = new SolidColorBrush(Colors.Red);
}
protected override void OnDetached()
{
}
}
}

Effect is added to button in xaml like below:

   <Button Text="Button">
        <Button.Effects>
            <local:FocusEffect />
        </Button.Effects>
    </Button>

The issue is that background is not changing on Pointer Enter Event. Instead it changes on Pointer Exit.
Any help will be appreciated!

Showing a picker after a button click

$
0
0

Hi,

I want to show a picker after a buttonclick to change the color of a boxview. How can I show/hide a picker in a button click event? This is my code:

public partial class MainPage : ContentPage
{
public MainPage ()
{
InitializeComponent ();
}

    Dictionary<string, Color> nameToColor = new Dictionary<string, Color>
    {
        { "Aqua", Color.Aqua },         { "Black", Color.Black },
        { "Blue", Color.Blue },         { "Fuschia", Color.Fuschia },
        { "Gray", Color.Gray },         { "Green", Color.Green },
        { "Lime", Color.Lime },         { "Maroon", Color.Maroon },
        { "Navy", Color.Navy },         { "Olive", Color.Olive },
        { "Purple", Color.Purple },     { "Red", Color.Red },
        { "Silver", Color.Silver },     { "Teal", Color.Teal },
        { "White", Color.White },       { "Yellow", Color.Yellow }
    };

    private void ChangeColorButton_Click(object sender, EventArgs e)
    {
        _showColorPicker ();
    }

    private void _showColorPicker() {
        Picker picker = new Picker
        {
            Title = "Color",
            VerticalOptions = LayoutOptions.CenterAndExpand
        };

        foreach (string colorName in nameToColor.Keys)
        {
            picker.Items.Add(colorName);
        }

        picker.SelectedIndexChanged += (sender, args) =>
        {
            if (picker.SelectedIndex > -1)
            {
                string colorName = picker.Items[picker.SelectedIndex];
                ColorBox.Color = nameToColor[colorName];
            }
        };
    }
}

How to get live/continious audio stream from mobile microphone

$
0
0

is it possible to get live audio stream from mobile mic with specified PCM format, so that I can use that stream in a socket connection.

Image above tabbedpage

$
0
0

How can I put an image above tabbedpage?

What alternatives do I have for an equal design?

Xaml set property conditionally

$
0
0

I have the following XAML:

<ffimg:CachedImage HeightRequest="400" WidthRequest="400" Source="{Binding ImageUrl}">
    <fffimg::CachedImage.Transformations>
        <fftransformations:CircleTransformation/>
    </ffimg::CachedImage.Transformations>
</ffimg::CachedImage>

I would like to set the <fftransformations:CircleTransformation/> only if : {Binding IsRoundImage}. Is it possible to do this directly in XAML? I have tried DataTriggers but it doesn't work.


Can you have a generic MessagingCenter subscripton that will accept messages from classes

$
0
0

Hi,

in my application I have multiple implementations of RFID readers and I have created an Interface than encapsulates common reader actions. So for example I have interface IReader, and then classes ReaderA, ReaderB which each holds it's own implementation of different reader and their action. The reader is a singleton inside my App class. Each Reader sends a message via MessagingCenter everytime when a new tag is detected.
Example of .Send method inside ReaderA class:

MessagingCenter.Send(this, "Rfid", new CustomTag
{
    Id = "123",
    ScannedDate = DateTime.UtcNow
});

So when I subscribe to the message inside my ContentPage, this will work:

MessagingCenter.Subscribe<ReaderA, CustomTag>(this, "Rfid", (sender, item) => {
    //TODO: process result
});

But since the actual implementation of reader will vary, this won't work when my reader will use an instance of ReaderB class. I tried to use the IReader as the sender type inside the subscribe method, but with no success. I also tried to create a base class (BaseReader) and to subscribe to it, send as it, etc. and nothing works. So the botton examples will never fire:

class ReaderA : BaseReader, IReader
{
    //...

}

MessagingCenter.Subscribe<IReader, CustomTag>(this, "Rfid", async (sender, item) => {
    //TODO: process result
});
MessagingCenter.Subscribe<BaseReader, CustomTag>(this, "Rfid", async (sender, item) => {
    //TODO: process result
});

Sure I could just have a separate subscription call for my ReaderB, but I would prefer to just make one generic subscription. Is it possible to do this and how to accomplish it? Thank you for all suggestions and provided answers :)

[UWP] ToolBarItem icon is not shown on first page

$
0
0

When my application loads, no icon is shown in my ToolBarItem. See below screenshot:

If I click a menu item that opens the same page again, then the icon shows correctly:

There isn't a lot of magic to my page, and the ToolBarItem is pretty simple:

Any ideas for why it doesn't show on first load?

How to open default contacts app in xamrin forms?

$
0
0

How to open default contacts app in xamrin forms?

Scrolling is not working in xamarin.Ios Editor control

$
0
0

we are displaying simple text in editor control when we assign the text to control from code section. scrolling is not working when i try to edit the text in editor control in ios application but for android it is working fine..

Change google map info window text when it is appearing

$
0
0

my current situation that i want when user click on marker i send a request to get clicked position address and show it in the info window it working for IOS but android has problems

GoogleMaps custom renderer in iOS -> NPE

$
0
0

I'm writing a project with a pcl and ios components. I'm following this sample:

https://github.com/xamarin/xamarin-forms-samples/blob/master/CustomRenderers/Map/Pin

Using it in conjunction with Xamarin.Forms.GoogleMaps NuGet package.

I'm facing a problem inside iOS renderer, because on row number 37 https://github.com/xamarin/xamarin-forms-samples/blob/master/CustomRenderers/Map/Pin/iOS/CustomMapRenderer.cs#L37 i will get always

var nativeMap = null

I can't understand what I'm missing

EDIT:
Debugging I get some more information. The problem seems to be Control as MKMapView casting, infact that casting returns null, Control seems to be GMSMapView type instead of MKMapView.

How to go ahead of this problem???

Setting button's IsEnabled to false does not disable button

$
0
0

I have observed that when setting a button's IsEnabled property to false, the button continues to be enabled.

This button is located at the bottom of the grid. I do not observe this behavior in other views though.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="auto" />
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition />
    </Grid.ColumnDefinitions>

    <ListView Grid.Row="0"  ItemsSource="{Binding Services}" SelectedItem="{Binding SelectedService}" HasUnevenRows="true">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <ViewCell.View>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>

                            <Label Grid.Row="0" Grid.ColumnSpan="2"  Text="{Binding Name}" />
                            <Label Grid.Row="1" Grid.Column="0" Text="Labor:" />
                            <Label Grid.Row="1" Grid.Column="1" Text="{Binding LaborCost, StringFormat='{}{0:c}'}"  />

                            <Label Grid.Row="2" Grid.Column="0" Text="Materials:" />
                            <Label Grid.Row="2" Grid.Column="1" Text="{Binding Materials, Converter={StaticResource MaterialsToCostConverter}, StringFormat='{}{0:c}'}}" />

                            <Label Grid.Row="3" Grid.ColumnSpan="2" Text="{Binding Description}" />
                        </Grid>
                    </ViewCell.View>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

    <Button Grid.Row="1" Grid.Column="0"  Text="Details" IsEnabled="False"
            Command="{Binding ViewService}"/>

</Grid>

TimeZone With UTC format

$
0
0

Hi,
i have to list out all the timezones like (UTC-12:00) International Date Line West......in PCL.

i can able to do with TimeZoneInfo.GetSystemTimeZones(). but this not displays UTC with name ... please help me to do this..

listview keyboard scroll on android app and xamarin.forms

$
0
0

hi

when i create new basic android app via xmarin and create listview with items in it i can automatically scroll the items via bluetooth keyboard
but when i create the same under xamarin.forms app i am not able to scroll using the bluetooth keyboard

is it a bug? i have to code it?

please advice i really stuck here

thanks.

How to detect text and search a location over mapview?

$
0
0

I added mapview using xamarin.forms.maps package. I wanted to add a searchbar field to search address and drop pin using search box.

How to add a SearchBar programmatically a search a location?

I tried the following:

var searchField = new SearchBar
{
Placeholder = "Enter search term"
};
searchField.SearchCommand = new Command(() => { if (searchField != null) { string.Format("Result: {0} is what you asked for.", searchField.Text); }
** // I don't get the text here**

Content = new StackLayout
{
Spacing = 0,
Children = {
searchField,
map,
buttons
}
};

Issue while opening Xamarin form from BroadcastReciever class

$
0
0

This is for tracking incoming and outgoing phone calls. I am pushing a Xamarin form in the application Navigation stack from BroadcastReciever class using following code:

var phoneAddPage = new SomePage();
Xamarin.Forms.Application.Current.MainPage = new NavigationPage(phoneAddPage);

The page is getting pushed properly as expected. Issue is the page is overlapped by Splash Screen when application is opened. The form is functioning properly, overlap is the only issue.

Animation on xamarin forms using Lottie dont work!

$
0
0

Hi,
anyone use the Lottie nugget to play animations on xamarin forms.
I tested a simple example that dont run, just appear on android emulator a blank window.

I install the Lottie nugets.

Here is my xaml page:

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

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

         xmlns:forms="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"

         x:Class="Example.Forms.MainPage">

    <forms:AnimationView 

            x:Name="AnimationView"

            Animation="LottieLogo1.json"

            Loop="True"

            AutoPlay="True"

            VerticalOptions="FillAndExpand"

            HorizontalOptions="FillAndExpand" />

I put the file "LottieLogo1.json" on Resources folder of the Droid Project.

Thanks

Viewing all 91519 articles
Browse latest View live


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