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

Xamarin Forms: How to highlight text and pause/play audio of text to speech?

$
0
0

I am using the xamarin essentials package for text to speech feature. When speech the text I need to highlight the corresponding text. Also, I need an option to pause/play the speech. Please see this video.

Screenshot:

enter image description here

How can I achieve highlight text feature and pause/play audio as the video?


How to add space between bullet and List item in a HTML text in Xamarin forms

$
0
0

Hi,

I am trying to load HTML content in a Label, for that i am getting data from web service as

Things to do with this announcement:

  • Identify items you stock that are impacted
  • Review your sales and stop reordering poor sellers to help sell down restricted product
  • Assign a captain to ensure all restricted product is removed July 1, 2020

Please reach out with any questions or concerns:

I need space between bullet point and List item(

items)

Can anyone tell me how to do this in xamarin forms.

Thanks

CollectionView bug

$
0
0

Hi guys! Im using Xamarin.Forms 4.7 in my project and have issue with CollectionView.
This bug appears only on iOS and is displayed in approximately one build out of 10. I guess that bottom tabbed page causes this issue. Is there any ways to fix this?

How to convert a picture path to mediafile?

$
0
0

I have a picture file path and I am trying to upload this picture to server. When I upload this picture to server I need it's GetStream() value. I will show a sample code, that I have used in another place:

var content = new MultipartFormDataContent();
content.Add(new StreamContent(_mediaFile.GetStream()), "\"file\"", $"\"{_mediaFile.Path}\"");
var response = await httpClient.PostAsync(new Uri("My REST API"), content);

if (response.IsSuccessStatusCode)
{
   //Success
}

Where _mediaFile is a MediaFile

private MediaFile _mediaFile;

But currently, I have only the picture path. So is there any way to convert the picture path to MediaFile or anyway way to get the GetStream() value of the picture path?

Pagination in Listview

$
0
0

Hi all, I have nearly 1000 records in my ListView I need to show 100 records in each page. Can any one please help me on how to add Pagination in ListView. Any sample code or proper link on how to implemented will be very helpful!!

Thank you.

Move in image only possible in two directions

$
0
0

Hi All,

I have a code where I have an image which the user can zoom and move the image when zoomed. I face two difficulties here and I hope someone can help:

  • I can move the image in only two directions: left and up. It seems to be fixed to the right and downward somehow.
  • I want that the user can only move the image left, right, up and down when zoomed. Moving the image can now already be done without any zooming, which looks a bit strange.

I have a small demo in the attachment (tested on Android).

Hope someone can help!

Regards, Ganesh

HTML Content not working properly on IOS

$
0
0

Hi everyone, I'm getting a headache to display some dashboards into my Xamarin Forms project, as you can see in the picture below it's working pretty nice at Android devices. However when it goes to IOS it doesn't work, the screen does not fill and expand and the view is not properly exhibiting in "Mobile Mode View",

I'm using a Tableau Desktop to make these dashboards and then I insert a EMBED into my HTML pages to then display it on my Xamarin, here's what I used to manage it to work, i followed Microsoft documentation to display the HTML content into a webview

And here is the Javascript embed API to display the dashboard:

    <div class='tableauPlaceholder' id='viz1587599706721' style='position: relative'>
            <noscript>
            <a href='#'>
                <img alt=' ' src='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Da&#47;DashboardEFColunasSample&#47;DashboardMainTest&#47;1_rss.png' style='border: none' />
                </a>
                </noscript>
            <object class='tableauViz'  style='display:none;'>
            <param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
            <param name='embed_code_version' value='3' />
            <param name='site_root' value='' />
            <param name='name' value='DashboardEFColunasSample&#47;DashboardMainTest' />
            <param name='tabs' value='no' />
            <param name='toolbar' value='yes' />
            <param name='static_image' value='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Da&#47;DashboardEFColunasSample&#47;DashboardMainTest&#47;1.png' />
            <param name='animate_transition' value='yes' />
            <param name='display_static_image' value='yes' />
            <param name='display_spinner' value='yes' />
            <param name='display_overlay' value='yes' />
            <param name='display_count' value='yes' />
            <param name='filter' value='publish=yes' />
                </object>
            </div>                
            <script type='text/javascript'>                   
                var divElement = document.getElementById('viz1587599706721');
                var vizElement = divElement.getElementsByTagName('object')[0];
                if (divElement.offsetWidth > 800) {
                    vizElement.style.width = '1100px';
                    vizElement.style.height = '627px';
                } else if (divElement.offsetWidth > 500) {
                    vizElement.style.width = '1100px';
                    vizElement.style.height = '627px';
                } else {
                    vizElement.style.width = '100%'; vizElement.style.height = '577px';
                } var scriptElement = document.createElement('script');
                scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
                vizElement.parentNode.insertBefore(scriptElement, vizElement);
            </script>

HERE IS THE XAML CODE:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:d="http://xamarin.com/schemas/2014/forms/design"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
                 mc:Ignorable="d"
                 android:TabbedPage.IsSwipePagingEnabled="False"
                 android:TabbedPage.ToolbarPlacement="Bottom"
                 BarBackgroundColor="#00143D"
                 BarTextColor="White"
                 Visual="Material"
                 SelectedTabColor="DeepSkyBlue"
                 UnselectedTabColor="White"
                 x:Class="AlgorixMobile.Views.FaturamentoeEbitdaView"
                 Title="Faturamento Ebitda">
        <TabbedPage.ToolbarItems>
            <ToolbarItem IconImageSource="diagrama.png" />
        </TabbedPage.ToolbarItems>
        <TabbedPage.Children>
            <ContentPage Title="Colunas" IconImageSource="lucro.png" >
                <StackLayout>
                    <WebView x:Name="Barras"
                       HorizontalOptions="{OnPlatform Android=FillAndExpand, iOS=FillAndExpand}"
                       VerticalOptions="FillAndExpand" />
                </StackLayout>
            </ContentPage>
            <ContentPage Title="Linhas" IconImageSource="estatisticas.png">
                <StackLayout>
                    <WebView x:Name="Linhas"
                             HorizontalOptions="FillAndExpand"
                             VerticalOptions="FillAndExpand" />
                </StackLayout>
            </ContentPage>
            <ContentPage Title="Ultimos 12 meses" IconImageSource="lucro.png" >
                <StackLayout>
                    <WebView x:Name="Ultimos12"
                             HorizontalOptions="FillAndExpand"
                             VerticalOptions="FillAndExpand" />
                </StackLayout>
            </ContentPage>
            <ContentPage Title="Anual" IconImageSource="lucro.png">
                <StackLayout>
                    <WebView x:Name="Anual"
                             HorizontalOptions="FillAndExpand"
                             VerticalOptions="FillAndExpand" />
                </StackLayout>
            </ContentPage>
        </TabbedPage.Children>
    </TabbedPage>

What I need is to make it work on IOS the same way as it is working at the Android, can anyone help ?

I mean is it possible to force the ios to recognize as a mobile device the HTML content if so how to make it shows on full screen mode?

Thanks in advance!

Is it correct to use Xamarin.Forms namespace in a ViewModel

$
0
0

I am a newbie in Xamarin.Forms and the architect in our team mentioned, if we wanted a clean architecture, we must avoid using Xamarin.Forms in ViewModel as it references Views directly so it actually doesn't decouple.

But in the most of the tutorials, guides I don't see this being followed.

Can anyone suggest what's the correct guideline, and how does it really support this decoupling? Does everyone follow the same?
Also, when I try to use buttonclick event via a Command class in the ViewModel, I can't use it without using Xamarin.Forms namespace.

How can I achieve pure decoupling without using the Command class?


My Button Command not working using FreshMVVM

$
0
0
Hello Devs! I was using FreshMVVM in my Xamarin Forms Project, I implement Button Command in my LoginPage but it seems the Button doesn't have any connection with the LoginPageModel, I use XF Material Library and the Register button which I bound to is the Last Control in the Page (to ease Navigation).
Here is the LoginPage.Xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns:local="clr-namespace:buziTrade.Pages"
xmlns:xamanimation="clr-namespace:Xamanimation;assembly=Xamanimation"
xmlns:material="clr-namespace:XF.Material.Forms.UI;assembly=XF.Material"
xmlns:yummy="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"
mc:Ignorable="d"
x:Class="buziTrade.Pages.LoginPage"
NavigationPage.HasNavigationBar="False">
<ContentPage.Resources>
<ResourceDictionary>

<local:MultiTriggerConverter x:Key="dataHasBeenEntered" />

<!--<xamanimation:StoryBoard
x:Key="InfoPanelAnimation"
Target="{x:Reference InfoPanel}">
<xamanimation:FadeToAnimation
Duration="50"
Opacity="1" />
<xamanimation:TranslateToAnimation
TranslateY="0"
Easing="CubicIn"
Duration="100" />
</xamanimation:StoryBoard>-->

<xamanimation:FadeInAnimation
x:Key="FlexLayoutAnimation"
Target="{x:Reference MainPanel}"
Duration="300"/>

</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<Grid x:Name="MainPanel">
<Grid VerticalOptions="Start">

<!--<yummy:PancakeView BackgroundColor="#275685" VerticalOptions="Start"
Padding="10">
<Label Text="Login Form" FontSize="14" TextColor="#FFFFFF"
FontAttributes="Bold"/>
</yummy:PancakeView>-->

<Frame BackgroundColor="#275685"
HorizontalOptions="Center" WidthRequest="30"
HeightRequest="30" CornerRadius="5"
Margin="0, 40, 0, 0">
<Label Text="bt" TextColor="White" HorizontalOptions="Center"
VerticalOptions="Center" FontSize="Large"
FontAttributes="Bold"/>
</Frame>
<Label Text="buziTrade"
TextColor="#275685" VerticalOptions="EndAndExpand"
HorizontalOptions="CenterAndExpand" Margin="0,0,0,-30"/>
</Grid>

<Grid VerticalOptions="CenterAndExpand" Margin="20,60,20,0">
<StackLayout>

<material:MaterialTextField Margin="0,0,0,30"
Placeholder="Username" x:Name="UserName"
InputType="Text" MaxLength="10" TintColor="#EC8D34"
FloatingPlaceholderFontSize="10" ShouldAnimateUnderline="True"
AlwaysShowUnderline="True"/>

<material:MaterialTextField
Placeholder="Password" x:Name="Password"
InputType="Password" MaxLength="8" TintColor="#EC8D34"
FloatingPlaceholderFontSize="10" ShouldAnimateUnderline="True"
AlwaysShowUnderline="True"/>

<StackLayout Orientation="Horizontal" VerticalOptions="End"
FlowDirection="RightToLeft" Margin="0,30,0,0">
<material:MaterialButton BackgroundColor="#275685"
CornerRadius="5" Margin="15, 10, 0, 0" Text="Login"
TextColor="#FFFFFF" ButtonType="Elevated"
x:Name="BtnLog2" IsEnabled="False">
<Button.Triggers>
<MultiTrigger TargetType="Button">
<MultiTrigger.Conditions>
<BindingCondition Binding="{Binding Source={x:Reference UserName},
Path=Text.Length,
Converter={StaticResource dataHasBeenEntered}}"
Value="True"/>
<BindingCondition Binding="{Binding Source={x:Reference Password},
Path=Text.Length,
Converter={StaticResource dataHasBeenEntered}}"
Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="IsEnabled" Value="True" />
</MultiTrigger>
</Button.Triggers>
</material:MaterialButton>

<material:MaterialButton
TextColor="Red" FontSize="13"
ButtonType="Flat"
BackgroundColor="Transparent"
PressedBackgroundColor="Transparent"
CornerRadius="5" Margin="0,10,0,0"
Text="Forgot Password!"
HorizontalOptions="EndAndExpand" />

<!--<material:MaterialButton
CornerRadius="5" Margin="0, 10, 0, 0"
Text="Forgot Password!" BackgroundColor="#FFFFFF"
TextColor="#FFFFFF" ButtonType="Text"
PressedBackgroundColor="Transparent"
x:Name="Btnforgot" HorizontalOptions="EndAndExpand"/>-->
</StackLayout>
</StackLayout>
</Grid>
<StackLayout Orientation="Horizontal" VerticalOptions="End" Margin="0, 0, 0, 90">
<BoxView HorizontalOptions="StartAndExpand" VerticalOptions="Center" BackgroundColor="#275685" HeightRequest="2"
WidthRequest="150"/>
<Label Text="OR" HorizontalOptions="Center" VerticalOptions="Center" TextColor="#275685"/>
<BoxView HorizontalOptions="EndAndExpand" VerticalOptions="Center" BackgroundColor="#275685" HeightRequest="2"
WidthRequest="150"/>
</StackLayout>

<material:MaterialButton
CornerRadius="5" Margin="0, 0, 0, 30"
Text="Register Here" BackgroundColor="#FFFFFF"
TextColor="#275685" ButtonType="Text"
PressedBackgroundColor="Transparent"
x:Name="BtnRegister" VerticalOptions="End"
Command="{Binding RegisterCommand}" />

</Grid>
</ContentPage.Content>
</ContentPage>

and this is the LoginPageModel:

using FreshMvvm;
using PropertyChanged;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;

namespace buziTrade.PageModels
{
[AddINotifyPropertyChangedInterface]
public class LoginPageModel : FreshBasePageModel
{
public ICommand RegisterCommand => new Command(async () => await RegisterPage());


public LoginPageModel()
{

}

public override void Init(object initData)
{
base.Init(initData);
}

private async Task RegisterPage()
{
await CoreMethods.PushPageModel<RegisterPageModel>();
}

}
}

@MichaelRidland @Martijn00

How to Apply Style to particular Class name Div (HTML text) in Xamarin forms

$
0
0

Hi,

I am trying to load HTML content in a Label. I am getting Data like

April 1:

Due to revised NSPS emission limits for new room heaters, several wood stoves currently stocked in the RSCs will not be EPA compliant in 2020 and need to be sold or destroyed by May 15. AS OF MAY 15, YOU CANNOT SELL THESE UNITS TO CONSUMERS.

Vendors will not be taking back inventory of these units, so you are advised to sell through any stock on hand prior to the May 15, 2020 deadline. All impacted units on-hand as of May 15 are deemed unsellable and will need to be salvaged.

Please see the list of impacted SKUs and previous notices about this upcoming stop sale below for additional details.

 

Feb. 26, 2020:

We have added a $100 Instant Savings ONLINE to two U.S. Stove Wood Burning Stoves to help sell-through current inventory. These stoves are Ace Nos. 4639712 (54000 BTU 900 sq. ft. Wood Stove – 1269E) and 4639720 (94000 BTU 1600 sq. ft. Wood Stove – 2469E). We will honor the $100 for any stores who price matches the online price. Please contact the Ace Retailer Care Center to complete the instant savings reimbursement process.

 

Dec. 13, 2019:

In 2020, the NSPS emission limit for new room heaters will be lowered to 2.0 grams per hour if tested with crib wood*, or 2.5 grams per hour if tested with cord wood*.

All new wood heating appliances subject to the New Source Performance Standard for New Residential Wood Heaters under the Clean Air Act offered for sale in the United States are required to meet these emission limits.

As a result, several wood stoves currently stocked in the RSCs will not be EPA compliant in 2020 and need to be sold or destroyed by May 15. AS OF MAY 15, YOU CANNOT SELL THESE UNITS TO CONSUMERS. We are working with all vendors on transition plans for all existing stoves impacted by this regulation. We will continue to post subsequent communication in addition to specific action plans for all impacted stoves. We are closely monitoring inventory in the RSCs as well to ensure we're able to supply the demand this season, but not put anyone at risk of overstock in the Spring.

Attached is the list of the impacted Pellet and Wood Burning Stoves that will need to be sold before the May 15 deadline. Setup of replacement SKUs are in process and will be communicated once available on ACENET.

Submitted by: Daniel Kosinski – Merchandising

I have a div with class name "MobileBody". I want to apply style to it.
I tried the below one but it is working for only IOS, for Android All style tags are displaying ...
if (DeviceInfo.Platform.ToString() == "iOS")
{
ParagraphDesc = ".mobileBody{font-family:Roboto Slab; font-size:14px}" + responseData.BodyContent;
}

Can any one help on this

Pass List to another View and Display it

$
0
0

Hi. I'm trying to pass a List from one view to another, using the MVVM pattern. In my project, I want to store the questions from a List (questions) into another list (errores) and I want to display "errores" in another view. Basically, whenever the wrong True/False button is pressed, I want to store the question into "errores".

Here's what I've tried:

{
    private List<string> errores;

    public RESULTSPAGE2(List<string> errores)
    {
        InitializeComponent();

        MainListView.ItemsSource = errores;


    }


    }
}

//RESULTSPAGE2.xaml
<ContentPage.Content>
        <StackLayout>
            <ListView 
             x:Name="MainListView"   />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>








class QuizPageModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    void OnPropertyChanged([CallerMemberName] string name = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }

    public List<Question> questions;

    List<string> errores = new List<string>();



    private string _textopregunta;

    public string TextoPregunta
    {
        get
        {
            return _textopregunta;
        }

        set
        {
            _textopregunta = value;
            OnPropertyChanged();
        }
    }

    //Add Color
    /* private Color _BackgroundFalseButton;

     public Color BackgroundFalseButton
     {
         get
         {
             return _BackgroundFalseButton;
         }
         set
         {
             _BackgroundFalseButton = value; //You must implement INotifyChanged
             OnPropertyChanged(nameof(BackgroundFalseButton));
         }

     }*/



    private bool _wrongAnswer;
    public bool WrongAnswer
    {
        get
        {
            return _wrongAnswer;
        }

        set
        {
            _wrongAnswer = value;
            OnPropertyChanged();
        }
    }


    private bool _currentAnswerValue;
    public bool CurrentAnswerValue
    {
        get
        {
            return _currentAnswerValue;
        }

        set
        {
            _currentAnswerValue = value;
            OnPropertyChanged();
        }
    }

    private int _totalQuestions;
    public int TotalQuestions
    {
        get
        {
            return _totalQuestions;
        }

        set
        {
            _totalQuestions = value;
            OnPropertyChanged();
            OnPropertyChanged(nameof(TitleText));
        }
    }

    private int _currentQuestionNumber;
    public int CurrentQuestionNumber
    {
        get
        {
            return _currentQuestionNumber;
        }

        set
        {
            _currentQuestionNumber = value;
            OnPropertyChanged();
            OnPropertyChanged(nameof(TitleText));
        }
    }

    public string TitleText
    {
        get { return $"Question {_currentQuestionNumber} of {_totalQuestions}"; }
    }

    private int score;

    private Random random;

    public Command AnsweredTrue { get; }
    public Command AnsweredFalse { get; }
    public string QuestionText { get; }



    public QuizPageModel()
    {
        // initialise RNG
       random = new Random();

        // populate question list - replace with external data source in production
        questions = new List<Question>()
        {
            new Question() { QuestionText="1=2", Answer=false } ,
            new Question() { QuestionText="2+2=3", Answer=false },
            ..........
        };



            // initialise quiz values
            TotalQuestions = questions.Count;
        CurrentQuestionNumber = 1;
        score = 0;

        // load first question
        LoadQuestion();



        //True/False

        AnsweredTrue = new Command<Question>(async (question) =>
        {
            Debug.WriteLine("True button pressed");


            /* AnsweredTrue = new Command(async () =>
             {
             Debug.WriteLine("True button pressed");*/

            // check if answer is correct
            if (_currentAnswerValue == true)

                score++;



            else
            {

                errores.Add(QuestionText);


            }


        // load next question or results page
        if (CurrentQuestionNumber < TotalQuestions)
        {
            // increase question counter
            CurrentQuestionNumber++;
            LoadQuestion();
        }
        else
        {
            Debug.WriteLine("End of Quiz");
            await ShowResults().ConfigureAwait(false);
        }
    });



        AnsweredFalse = new Command(async () =>
        {
            Debug.WriteLine("False button pressed");



            // check if answer is correct
            if (_currentAnswerValue == false)
                score++;

            else
            {
                errores.Add(QuestionText);
                //_wrongAnswer = true;

            }


        /*    if (_wrongAnswer == true)
            {
                errores.Add(QuestionText);

            }

            */

        // load next question or results page
        if (CurrentQuestionNumber < TotalQuestions)
        {
            // increase question counter
            CurrentQuestionNumber++;
            LoadQuestion();
        }
        else
        {
            Debug.WriteLine("End of Quiz");
            await ShowResults().ConfigureAwait(false);
        }
    });
    }


    private void LoadQuestion()
    {
        var index = random.Next(questions.Count);
        TextoPregunta = questions[index].QuestionText;
        CurrentAnswerValue = questions[index].Answer;
        questions.RemoveAt(index);
    }

    // private async Task ShowResults() => await Application.Current.MainPage.Navigation.PushAsync(new LVTest(score, _totalQuestions, errores)).ConfigureAwait(false);
    private async Task ShowResults() => await Application.Current.MainPage.Navigation.PushAsync(new RESULTSPAGE2(errores));

}

}

TabbedPage event on tab click or refresh tab when same tab is clicked?

$
0
0

I'm using a TabbedPage with Xamarin.Forms, and when a user is already on Tab 2, and clicks on Tab 2, I'd either like that tab to reload, or i'd like to run my own custom code to refresh the page.

I have been trying to find any sort of event I could hook into, or a way to do this with custom renderers but have been unable to find anything. What's the simplest way to do this?

Thanks!

iOS App crashing when binding to Text & IsVisible

$
0
0

I'm having issues with binding in iOS. We have numerous forms in our app and they're broadly set out as per the example with an Entry and an associated label for validation feedback - we're using FluentValidation for this. The label is hidden unless there are errors to show, this is so they take up no space on the interace when not required.

<Entry x:Name="UsernameEntry" 
    Placeholder="{Binding UILabelLoginName}"
    IsTextPredictionEnabled="False"
    PlaceholderColor="#333333"
    TextColor="#000000" 
    ReturnType="Done"
        Text="{Binding LoginName.Value}"
        InputTransparent="False">
    <Entry.Behaviors>
        <behaviors:EventToCommandBehavior
            Command="{Binding ClearValidationCommand}"
            CommandParameter="LoginName"
            EventName="Focused" />
    </Entry.Behaviors>
</Entry>

<Label
    IsVisible="{Binding LoginName.IsValid, Converter={StaticResource InverseBoolean}}"
    Style="{StaticResource ErrorLabelStyle}"
        Text="{Binding LoginName.FirstError}" />

This works lovely in Android, in iOS though the binding to IsVisible crashes the app. If we set IsVisible to true as opposed to binding it and set a fixed HeightRequest then it works fine but I don't want empty labels taking up space within the forms.

Android - On Load

Android - On Error

iOS - On Load (IsVisible set to Binding)

iOS - On Error (IsVisible set to Binding)

  • Crash

iOS - On Load (IsVisible set to True)

iOS - On Error (IsVisible set to True)

The exception at the time of the crash is,

Object reference not set to an instance of an object

at Xamarin.Forms.Platform.iOS.VisualElementTracker.UpdateClip () [0x00072] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:413
at Xamarin.Forms.Platform.iOS.VisualElementTracker.UpdateNativeControl () [0x0006c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:386
at Xamarin.Forms.Platform.iOS.VisualElementTracker.HandlePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00064] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:97
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:353
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:461
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindablePropertyKey propertyKey, System.Object value) [0x0000e] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:318
at Xamarin.Forms.VisualElement.set_Height (System.Double value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:324
at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x0001a] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1081
at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:316
at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:708
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:178
at Xamarin.Forms.TemplatedView.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:29
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812
at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1083
at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:316
at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:708
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.View child, Xamarin.Forms.Rectangle region, Xamarin.Forms.SizeRequest childSizeRequest) [0x00225] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:319
at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00081] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:65
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812
at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/Foundation/NSAction.cs:152
--- End of stack trace from previous location where exception was thrown ---

at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at xxxx.iOS.Application.Main (System.String[] args) [0x00002] in C:\xxxx\xxxx.iOS\Main.cs:19

Any guidance would be very much appreciated!

Thanks

It's possible to add Tap gesture to the Entry?

$
0
0

Hi All,
As I wrote in the title, it's possible to add Tap gesture to the Entry?
This code works for Label but doesn't work for Entry:

var tapEntryRecognizer = new TapGestureRecognizer(); tapFocusEntryRecognizer.Tapped += async (s, e) => { Console.WriteLine("tapped"); }; tapEntry.GestureRecognizers.Add(tapFocusEntryRecognizer);

How to insert badge in botttom tab on shell page?

$
0
0

I searched alot on internet but found no solution..Badge can be easily inserted in tabbed page but i am using Shell page..Anyone have code how to show badge in bottom tab in shell page?


VisualStateManager and nested controls

$
0
0

Hello people!

I'm trying to use VisualStateManager for a more consistent state change setup. My problem is, it doesn't seem to be able to recognize components that lie within other containers. Take for instance the following xaml:

            <StackLayout x:Name="CMD" Orientation="Horizontal"  BackgroundColor="Transparent"
                         Margin="0,0,5,0" IsEnabled="False">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup Name="CommonStates">
                        <VisualState Name="Disabled">
                            <VisualState.Setters>
                                <Setter TargetName="icon"
                                        Property="Label.TextColor"
                                        Value="{DynamicResource colors/disabled}" />
                                <Setter TargetName="text"
                                        Property="Label.TextColor"
                                        Value="{DynamicResource colors/disabled}" />
                            </VisualState.Setters>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid ColumnDefinitions="Auto,Auto,*">
                    <Label Grid.Column="0"
                                     WidthRequest="20"
                                     HeightRequest="20"
                                     Margin="0,0,10,0"
                                     Text="X"
                                     x:Name="icon" />
                    <Label Grid.Column="1"
                                  x:Name="text"
                                  Text="{Binding AddItemText}"
                                  TextColor="{DynamicResource colors/accent}"/>
                </Grid>
            </StackLayout>

This is just a representation of the original code, which contains custom controls - but the error is the same:

"InvalidOperationException: 'this element is not in a namescope'"

This only happens when the IsEnabled="False" property is set in the parent component.

In my real code, the enabled state is set based on a series of conditions, and when trying to set the IsEnabled property in code, I get a NullReferenceException in the Setter... presumably because it can't find the item in question.

Is this a known problem? Is there a solution to this?

How to get the serial number for a device with android 10 (API level 29)?

$
0
0

Hello,

As you can read here, https://developer.android.com/reference/android/os/Build#getSerial(),
from API level 29 and after, asking for the device's serial number throws an exception.

Is there a way to get the serial number from a device regardless of its API level?

Or is there a unique identifier of the device, that he will remain forever the same, and that its available to the user and to me (by code)??
I want the user to give me the identifier so I can register the device manually, but after that I want to read the identifier for the code...

My app maybe installed to user's personal phones so I do not want anything special like profile owner or root apps or stuff like that...

Thanks!!!

Need equivalent to an Android Activity for UWP & iOS

$
0
0

I got on GitHub this project to access Google Drive using Xamarin.Forms solution. Good that it works perfectly for Android. I wanted to extend to iOS & UWP. Google Drive API needs an Android Activity 'Custom URL Schem Interceptor'. I need how to implement it for iOS & UWP. The android activity code is given below. Someone might have already done that I hope.

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using System;
using Xamarin.Auth;

namespace XFCloudStorage.Droid
{
    [Activity(Label = "CustomUrlSchemeInterceptor", NoHistory = true, LaunchMode = LaunchMode.SingleTop)]
    [IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataSchemes = new[] { "com.esmsmartsolutions.xfcloudstorage" }, DataPath = "/oauth2redirect")]
    public class ActivityCustomUrlSchemeInterceptor : Activity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            global::Android.Net.Uri uri_android = Intent.Data;
            CustomTabsConfiguration.CustomTabsClosingMessage = null;
            var uri = new Uri(Intent.Data.ToString());
            AuthenticatorHelper.OAuth2Authenticator.OnPageLoading(uri);
            var intent = new Intent(this, typeof(MainActivity));
            intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
            StartActivity(intent);
            this.Finish();
            return;
        }
    }
}

Works fine on emulator, but cause deployment error on real device

$
0
0

I worked with VS 2017 until recently, and changed to VS 2019.
I also updated Xamarin.Forms

I try a simple app with a service, which works fine on the emulator.
When I try to run it on a real device, I get the next deployment error:

ADB0010: Deployment failedMono.AndroidTools.InstallFailedException: Unexpected install output: pkg: /data/local/tmp/com.companyname.tryservice_proj-Signed.apkFailure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED] at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\963\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 348

In my searching I've seen that possible reason can be that the name of the package begins with a Capital letter.
I've checked in AndroidManifest.xml and it begin with a small letter as it should

Any suggestion will be appreciated.

Polygon binding listview problem render

$
0
0

Good evening, I'm trying to create a listview with mvvm model with inside it a "Polygon" element in the item-template.
I have a button inside that allows you to hide / show elements and the RefreshListViewItem method is called from code at the click of the button .
On refreshing it would appear that the "Polygon" loses the data binding of the model.
Is anyone else having this problem?
Thank you!

Viewing all 91519 articles
Browse latest View live


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