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

Build an Alphabet listview sort with Pan Gesture

$
0
0

Hi all,

I'm implement a new listview with Alphabet sort pane in the right screen. For example, that sort pane have A-Z chars. When I pan at A, the listview will sort start with A letter.

I called it listview but it's totally made from stacklayout which put in the Scrollview because of complex requirement from the Customer, so I cannot use the native listview control.

My question is, when I'm doing Pan gesture with that Alphabet, how can I know that I'm running at the A letter or B, C letter?

The next question is, how to scroll to specific item in the StackLayout (this stacklayout is put inside a ScrollView) ?

Do you have any idea about those?

Thank you so much,


Update AbsoluteLayout bounds in parent Page from ContentView

$
0
0

Hi all,

I have a custom control name ButtonX (actually is a ContentView which contains few labels & image). This button is placed inside an AbsoluteLayout of MainPage. When user clicks on this button, I would like to update its position or size by using AbsoluteLayout.SetLayoutBounds method. But it doesn't work. Remember that, I update the bounds in ButtonX code, not in the MainPage code.

I have no idea how to do that, could you please help me to figure out the cause?

Thanks & best regards,

Webview text losses selection on button tap in ios.

$
0
0

Whenever i select some text in webview and clicks on some other button it looses the selection. Problem is only with ios, it works perfectly in android. Any sugeestions how to persist the selection. TIA. @JamesMontemagno @SamanthaHouts

Copy attached properties to new instance in xamarin forms

$
0
0

I am creating new instance of grid object which have two labels as following.


<Grid.ColumnDefinitions>


</Grid.ColumnDefinitions>
<Grid.RowDefinitions>

</Grid.RowDefinitions>


I am using Activator.CreateInstance method as given below:

Grid ClonedView =(Grid) Activator.CreateInstance(Grid.GetType());

        foreach (PropertyInfo propertyInfo in Grid.GetType().GetProperties())
        {
            if (propertyInfo.CanRead && propertyInfo.CanWrite  )
            {

                object PropertyValue = propertyInfo.GetValue(Grid, null);

                propertyInfo.SetValue(ClonedView, PropertyValue);

            }
        }

When I use this ClonedView in my page, but Cloned Grid don't understand that Label2 should appear in second column of grid. I did a lot of research on it but could not find any solution. Please let me know if anybody has any solutions.

thanks

Custom sound from FCM Notification?

$
0
0

Is there any way to play custom sound on notification receive(firebase notification) for both iOS and Android?(even if app is closed).

Why xamarin forum mobile application does not exist?

$
0
0

Open source forum application.
Wouldn't it be good for developers and the community?
Or is there? I could not find
Thanks community

Debugging "Failed to create archive zzz" - "An item with the same key has already been added"

$
0
0

I am having a nightmare of a time generating my APK file for my Android Xamarin.Forms app.

I have gotten Archive to work a few times but 90% of the time I get the error "An item with the same key has already been added". How do I debug this to see why I am getting this error?

I have tried:
1. Cleaning the solution and building and then archiving
2. Cleaning the solution, deleting all previous archives, bumping up the android app version number, and then going straight to Archive
3. About 300 hundred other combinations of the above (with and without clean builds) after adding/clearing various build settings

Custom context menu for ViewCell


How to make ViewCell.ContextActions conditional

$
0
0

I have ViewCell.ContaxtActions in my Listview, which has List of MenuItems like below

                    <ViewCell.ContextActions>
                      <MenuItem Clicked="OnEdit"          Text="{model:Translate Generic_Edit}"             />                         
                      <MenuItem Clicked="OnMulticalculus" Text="{model:Translate Generic_MultiCalculus}"    />
                    </ViewCell.ContextActions>

I would like to make menuitems visible on condition. For example, for certain condition, only edit menu should be visible and other menu should be invisible.

Can anyone help to make conditional Context menu in listview?

Thanks,
Vinu

myObjType.GetTypeInfo().DeclaredProperties.FirstOrDefault(p => p.CanRead) == null

$
0
0

Hi everybody.

I have two classes, that are mostly identical.

Since the latest updates of visual studio, all plugins, packages and anything else the TypeInfo of one of these classes is not determined as expected.
That causes sqlite to fail when creating a table for this class.

It would be great, if anyone can explain whats wrong here.

var obj1 = typeof(Data.Upgrade13To14.AnalysisViewLineUpgrade);
var info1 = obj1.GetTypeInfo();
var prop1 = info1.DeclaredProperties;
var readableprop1 = prop1.FirstOrDefault(p => p.CanRead); // not null :)

var obj2 = typeof(Data.Upgrade13To14.AnalysisViewLineNew);
var info2 = obj2.GetTypeInfo();
var prop2 = info2.DeclaredProperties;
var readableprop2 = prop2.FirstOrDefault(p => p.CanRead); // !!! null :(

Another symptom is, that the object inspection does not
show the properties of the instances of the corrupted class.

Upgrade13To14.AnalysisViewLineUpgrade inst1 = new Upgrade13To14.AnalysisViewLineUpgrade();
inst1.AnalysisViewId = 4;

Upgrade13To14.AnalysisViewLineNew inst2 = new Upgrade13To14.AnalysisViewLineNew();
inst2.AnalysisViewId = 4;

As this is my first post here, I am not allowed to attach pictures of screenshots. All properties of variable inst1 are shown. Either the public nor the "non-public"-members of the variable inst2 are listed.

Here is some environment information:
Mac OS X 10.14.4
Visual Studio Community 2019 for Mac Version 8.0.5 (build 9)
Mono 5.18.1.3 (2018-08/fdb26b0a445) (64-bit)
NETStandard.Library (2.0.3)
sqlite-net-pcl (1.5.231)

And here are the two classes:

  1. Working class

using System;
using SQLite;

namespace Library.FinanceManager.Data.Upgrade13To14
{
[Table("AnalysisViewLineUpgrade")]
public class AnalysisViewLineUpgrade
{
public enum LineType {Formula, LedgerSumCategory, LedgerSumRest, JournalLineSumCategory, JournalLineSumRest }
public enum PositiveNegative {All, Positive, Negative }
public enum DisplayType { Normal, Hidden, Strong, BackgroundIfNul, HiddenIfNul, NormalIfNul, HiddenIfNotNul, NormalIfNotNul }

public AnalysisViewLineUpgrade()
{
}

[PrimaryKey, AutoIncrement]
public int EntryNo {get;set;}
public int AnalysisViewId { get; set; }
public int LineNo { get; set; }

public LineType Type { get; set; }
public PositiveNegative ValueType { get; set; } = PositiveNegative.All;
[MaxLength(50)]
public string Description { get; set; }

[MaxLength(50)]
public string Formula { get; set; }
public DisplayType Display { get; set; }
public bool CalculateAverage { get; set; }

internal Data.Upgrade13To14.AnalysisViewLineNew Convert()
{
return new AnalysisViewLineNew()
{
ValueType = (Data.Upgrade13To14.AnalysisViewLineNew.PositiveNegative)ValueType,
AnalysisViewId = AnalysisViewId,
CalculateAverage = CalculateAverage,
Description = Description,
Display = (Data.Upgrade13To14.AnalysisViewLineNew.DisplayType)Display,
EntryNo = EntryNo,
Formula = Formula,
LineNo = LineNo,
Type = (Data.Upgrade13To14.AnalysisViewLineNew.LineType)Type
};
}
}
}

  1. Corrupt class

using System;
using SQLite;

namespace Library.FinanceManager.Data.Upgrade13To14
{
[Table("AnalysisViewLine")]
public class AnalysisViewLineNew
{
public enum LineType {Formula, LedgerSumCategory, LedgerSumRest, JournalLineSumCategory, JournalLineSumRest }
public enum PositiveNegative {All, Positive, Negative }
public enum DisplayType { Normal, Hidden, Strong, BackgroundIfNul, HiddenIfNul, NormalIfNul, HiddenIfNotNul, NormalIfNotNul }

public AnalysisViewLineNew()
{
}

[PrimaryKey, AutoIncrement]
public int EntryNo { get; set; }
public int AnalysisViewId { get; set; }
public int LineNo { get; set; }

public LineType Type { get; set; }
public PositiveNegative ValueType { get; set; } = PositiveNegative.All;
[MaxLength(50)]
public string Description { get; set; }

[MaxLength(50)]
public string Formula { get; set; }
public DisplayType Display { get; set; }
public bool CalculateAverage { get; set; }

}
}

Thanks in advance.

Martin

HotReload LiveReload LiveXaml [Mac] [Windows] [nuget package] [opensource]

How to put colour in Safe Area on iOS

$
0
0


How to put a background colour in the safe area similar to the red colour using Xamarin Forms?

Thanks

Make the text of a label fill up the container (auto font size)

$
0
0

How do I make a label always fill up the container by setting the biggest font size that allows all its text to fit the container?

There's Viewbox control in UWP. But there is no equivalence in Xamarin.Forms.

One way I can think of is to start with the biggest font size and iteratively reduce the size until no overflow occurs. This brings to another question. Is there a way to detect text overflow in a label?

Setup style for label

$
0
0

I have many labels with needs the same style, which is different for each platform. Right now I have this code:

But I have to set all the labels with this. Is there a way to define a style and ref it to all the labels instead?

Also FontAttributes are the same for both platforms, so how do I define in only once?

Xamarin Maps - Adding multiple destinations on a map and show optimum route navigation to a driver

$
0
0

Hi,

I am working on Xamarin forms and I have placed multiple points (destinations) on Xamarin maps and now I want my company drivers to show the optimise path for driving with the navigation.

I would like to know that is there any possibility to achieve the above task in Xamarin cross platform app, with multiple destinations and begin the navigation for the driver.

Any help, advise and sample source code will be really appreciated.


Adjust content to show Editor when keyboard is up, on a page with a ListView

$
0
0

I am working on a text-messaging style chat app, where there is a ListView showing the conversation in speech bubbles, and an Editor and a Send button at the bottom of the page. When the Editor is focused, the keyboard covers up the Editor making it impossible to see what you're actually typing.

The conventional solution to this in Xamarin.Forms is to wrap the page content (at least what you want to move for the keyboard) in a ScrollView, but that doesn't work in this scenario because nested scrollable controls (ListView inside a ScrollView) don't play nice in Forms.

Has anyone else found a cross-platform solution for this?

ZXing - defining scanning area

$
0
0

Hi everyone,
can I define scanning area in ZXing.Net.Mobile? I would like to scaned only center of screen.
I using ZXingScannerView and ZXingDefaultOverlay.

<zxing:ZXingScannerView Options="{Binding ScannerOptions}" IsScanning="{Binding IsScanning}" IsAnalyzing="{Binding IsAnalyzing}" IsEnabled="True" IsTorchOn="{Binding TorchOn, Mode=TwoWay}" Result="{Binding Result, Mode=TwoWay}" ScanResultCommand="{Binding ScanCommand}" /> <zxing:ZXingDefaultOverlay Opacity="0.9" />

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?

Cannot change Navigation page barbackgroundcolor programmatically

$
0
0

Hi
Wondering if is possible to change the navigation bar background programmatically
without using renderers.

I have an app that uses prism not that matters .
I have a masterpage and in my app.xaml I have the following

     <Style TargetType="NavigationPage">
        <Setter Property="BarBackgroundColor" Value="OrangeRed" />
        <Setter Property="BarTextColor" Value="Blue" />
      </Style>

so far so good!!!

Now when I go to a particular page I need to change the BarBackgroundColor.

Whatever I tried did not work(below code anywhere is always null!!)

        //does not work as navigationPage is null
        var navigationPage = App.Current.MainPage as NavigationPage;
        navigationPage.BarBackgroundColor = Color.Red;


I even created a class :MyNavigationPage and injected it and still does not work

public class MyNavigationPage : Xamarin.Forms.NavigationPage, INavigationPageOptions, IDestructible
{
    public MyNavigationPage()
    {

    }
}
     private readonly myNavigationPage navPage;

    public MenuViewModel(INavigationService navigationService,
    MyNavigationPage navigationPage) : base(navigationService)
    {
        this.navPage = navigationPage;
    }
    private void OnMenuItemTapped(MasterMenuItem menuItem)
    {
       navPage.BarBackgroundColor=Color.Red;
    }

    }

any samples out there where it works!!!
Is this a bug?

many thanks

Speech Recognizer error on IOS

$
0
0

I have implemented this code in my APP. https://github.com/dev-aritra/XFSpeech
Everything works on android. In IOS, when I run the "_speechRecognizer.GetRecognitionTask ..." instruction, I get this error:
{The operation couldn’t be completed. (kAFAssistantErrorDomain error 216.)}

Thanks in advance

Viewing all 91519 articles
Browse latest View live


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