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

Unable to change ListView.ItemTemplate in code behind in iOS of a Xamarin.Forms app

$
0
0

First I thought it was due to ToolbarItem with Order="Secondary" was not functional in iOS. Unfortunately I didn't put breakpoint and debugged it when I posted the above thing.

But after putting the breakpoint and debugging I found that the setting ItemTemplate in an event was not effective. The pros may tell me if it is a bug.

First, the postings by @NMackay and @ClintStLaurent in this thread confirmed that the way that I was accessing the StaticResource in the code is correct.

Then I found this post on StackOverflow which hinted me what may be wrong. It was mentioned that one has to refresh the ListView several times before the chanted ItemTemplate is effective. And I found that I will have to pull-to-refresh as many times as the number of rows visible. Still the new Itemtemplate is not applied to the top most item.

My code is as below:

    <ContentPage.Content>
        <StackLayout>
            <ListView x:Name="ItemsListView"
                      ItemsSource="{Binding ToDoPlusItems}"
                      VerticalOptions="FillAndExpand"
                      HasUnevenRows="true"
                      RefreshCommand="{Binding LoadItemsCommand}"
                      IsPullToRefreshEnabled="true"
                      IsRefreshing="{Binding IsBusy, Mode=OneWay}"
                      CachingStrategy="RecycleElement"
                      ItemTemplate="{StaticResource ItemTemplateNonFramed}">
                <ListView.GestureRecognizers>
                    <TapGestureRecognizer Tapped="GstrDoubleTapListItem_Tapped"
                                          NumberOfTapsRequired="2" />
                </ListView.GestureRecognizers>
            </ListView>
        </StackLayout>
    </ContentPage.Content>


        <ToolbarItem Text="Show Abridged"
                     Clicked="ShowAbridged_Clicked"
                     Order="Secondary" />
        <ToolbarItem Text="Show More"
                     Activated="ShowMore_Clicked"
                     Order="Secondary" />


        private void ShowAbridged_Clicked(object sender, EventArgs e)
        {
            ItemsListView.ItemTemplate = (DataTemplate)this.Resources["ItemTemplateNonFramed"];
        }

        private void ShowMore_Clicked(object sender, EventArgs e)
        {
            var template = this.Resources["ItemTemplateFramedShort"] as DataTemplate;
            ItemsListView.ItemTemplate = template;
        }

How to open specific page after clicking on notification when the app is closed using app center

$
0
0

Hi,

Kindly let me know How to open specific page after clicking on notification when the app is closed using app center push notification?

Is there any File/Image Upload Control in xamarin forms

$
0
0

Hi,

Is the any control for File/Image Upload in xamarin forms

When you click the button, the same page is opened multiple times. How can I fix this?

Xamarin.plugin.media 4.0.1.5 when updated throws runtime exception

$
0
0

The target SDK Version is set to 28. Have updated my xamarin.plugin.media to 4.0.1.5.It throws runtime exception.

VS Community Edition 15.8 Xamarin.android - 9.0.0.17

Can anyone please advice?

Exeption error:

Unhandled Exception: Java.Lang.RuntimeException: Unable to start activity ComponentInfo{com.psav.lighthouseuat/md53bdc6881122b82bfd2b961d262dd095c.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.ContentFrameLayout.setAttachListener(android.support.v7.widget.ContentFrameLayout$OnAttachListener)' on a null object reference

Below are the files where the code is added upon updating the plugin.media to latest version.

1) AndroidManifest.xml

2) MainActivity.cs


4) Assemblyinfo.cs

5) Added new folder called xml into Resources folder and added a new XML file called file_paths.xml

6) Packages.config


The application could not be started. Ensure that the application has been installed to the target d

$
0
0

this one again!!!!

The application could not be started. Ensure that the application has been installed to the target device and has a launchable activity (MainLauncher = true).

Additionally, check Build->Configuration Manager to ensure this project is set to succcsfully
for this configuration.

[1]
I have deleted previiouse APK from device end reassure no remaining other previews APK that might exist with the package or app name on the device.
try to change the app/package name...
[2]
tried the adb command prompt to delete the previous apk on cash..
[3]
manually clean and rebuild..
[4]
reboot the device
[5]
BUT: reopen Visual Studio on administrative mode - works!!

it works but in my case, it's taking a very long time to start work again on my project until everything compiled this and that...

so: if you have a different way to solve this issue and you would like to share.. it will be awesome

Platform dependent ListView.CachingStrategy does not work

$
0
0

I try to set the CachingStrategy on my listview per platform like this:

    <ListView.CachingStrategy>     
        <OnPlatform x:TypeArguments="ListViewCachingStrategy" iOS="RetainElement" Android="RecycleElement" />   
    </ListView.CachingStrategy>

And it results in the following error:

Position 54:10. Cannot assign property "CachingStrategy": Property does not exist, or is not assignable, or mismatching type between value and property

I also tried this:

<x:Arguments>
    <ListViewCachingStrategy>
        <OnPlatform x:TypeArguments="ListViewCachingStrategy" iOS="RetainElement" Android="RecycleElement"/>
    </ListViewCachingStrategy>
</x:Arguments>

Same result. Any ideas?

CachingStrategy OnPlatform axml

$
0
0

Hello, I would like to choose the Caching Strategy for each platform.
My code is as follows but does not work:

<ListView> <ListView.CachingStrategy> <OnPlatform x:TypeArguments="x:String" iOS="RetainElement" Android="RecycleElement" /> </ListView.CachingStrategy> <ListView.ItemTemplate> <DataTemplate> <ViewCell> ... </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

How can I do it?

Thank you.


OKTA SSO integration with SAML and WS-Federation

$
0
0

In our Xamarin.forms app, we want to support SSO with OKTA. We were able to implement SSO feature using "OpenId Connect" but we also want to use SSO with SAML 2.0 and WS-Federation

My question here is can we integrate OKTA SSO with SAML or WS-Federation in Xamarin.Forms? If 'Yes' any help link is appreciated here.

Assign picture to Image control from gallery and Keep it assigned before load the server.?

$
0
0

I have a list view of employee page. Click on each employee display detail page where I can load a picture to image box for each employee to save when I have internet connection. When I go back to listview I lose the image that I have assign for the previous employee. How to keep that image attached to image control (box)

Xamarin Controls or C# Class (object) data storage

$
0
0

Hi All,

Just wanted to know where c# (list) class stored the data in which memory (RAM or ROM).
As far as I know, when object is created the space is allocated for it's member (Variable/Properties or function) and stored all the data in RAM. So is it possible to access that data outside scope.

Add Watermark on Video Recorder

$
0
0

Hello All, i want to add company watermark in both iOS and android.i am use plugin.media for record video.
if anyone have suggestion for complete this task

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...

how to loading images from gallery?

$
0
0

I'm planning an app for cross-platform and i can not loading images from gallery.

Sliding Panel like native Google/Apple Maps

$
0
0

Hello,

I am looking for a sliding panel that slides up from bottom and is draggable, similar to what native maps provide on iOS and Android platforms. I would really appreciate if someone can help. I tried DKSlidingPanel but its very hard to customize it (since it has extra UI bits that we don't need).

Thanks

AP


Xamarin.Forms vs Flutter

$
0
0

Hi all
Thomas Burkhart has posted an interesting small review to Flutter (a relative new challenger to .forms) including his personal compare between .forms and Flutter.

As the link was included in the “Weekly Xamarin” newsletter and there also already were articles to Flutter published in the visuals studio magazine (links see below), I think, it’s O.K. to publish this thread here...

As I think, this is interesting for many users, I post the link here:
https://www.burkharts.net/apps/blog/flutter-the-new-kid-on-the-block/?utm_campaign=Weekly+Xamarin&amp;utm_medium=email&amp;utm_source=Weekly_Xamarin_150

Further, also Aloïs Deniel (another Xamarin user) has posted detailed information’s to Flutter a longer time ago here:
https://aloisdeniel.github.io/flutter-introduction/

I think, both postings together will give a good overview to Flutter (from the point of view of Xamarin users).

Link #1 to article in visual studio magazine:
https://visualstudiomagazine.com/articles/2017/12/04/flutter-challenges-xamarin.aspx

Link #2 to article in visual studio magazine:
https://visualstudiomagazine.com/articles/2018/03/01/flutter-xamarin.aspx

Link to a further “high level” comparison Xamarin / Flutter and React native:
http://blog.novoda.com/react-native-flutter-xamarin-a-comparison/

@ThomasBurkhart and @AloisDeniel
First, many thanks for your good work! :smile:

@ThomasBurkhart:
I can fully agree with your findings regarding the “Xamarin tool-chain”.
My personal opinion (without testing Flutter):

  • Looks very promising and interesting (especially “It just works”, fast build time, very fast start-up).
  • Negative points for me are: it seems that there is no integration in VS professional (MS will know the reason for), no direct interface to the device functions, future not secured, no direct support for build iOS on a windows machine

I will definitely keep an eye on Flutter and - as soon as my nerves are completely destroyed with Xamain.Forms - give it a try.

Thanks again

Maybe, also other users want to share their opinions here....?

Messaging Center called twice in xamarin forms

$
0
0
MessagingCenter.Subscribe<string>(this, "LocationName", (value) =>
                {
                    FullPathName.Text = value;
                });

While I set a break point and notice that This MessagingCenter.Subscribe called twice.
How to solve this?

Using declarative style C# instead of XAML - should Xamarin redirect XAML efforts elsewhere?

$
0
0

Introduction

Miguel tweeted:
"I should have never added Xaml and instead invented our own ...", expressing regrets about having to deal with XAML (standardization) problems.

My response was:
"I would applaud dropping XAML altogether. Advancements in C# (declarative syntax) have eliminated any advantages of a separate markup language for years. Why would you want to hand-code an object serialization format? Why waste time on duplicating dev tools for features that c# already offers?"

David expressed an interest to see how I have been creating Xamarin Forms markup in declarative style C#, instead of in XAML, for the past few years. So I write this post to provide a concrete example, and share the reasoning behind my remark (which was deliberately lacking nuance - it is Twitter after all).

Redirecting Xamarin IDE team effort

Why do I spend time on this? In the past years I only experienced advantages from using declarative C# instead of XAML. Given that the core challenge for the Xamarin IDE teams remains to improve the developer productivity, I would love to see some of the effort now being spent on (imo redundant) XAML tooling to be redirected towards reducing IDE bugs and speeding up the dev cycle, i.e. Live Player.

I recently investigated Google's Flutter (build beautiful native apps in record time), which by design has no separate language for markup and which offers hot reload - which is like a Xamarin Live Player without any limitations and a refresh time of 400-600 ms (I checked on devices and emulators). This is what I want from Xamarin!

This is the competition Xamarin is facing today. Some developers are already switching from Xamarin to Flutter because of developer tooling productivity, which apparently can be more important than language or framework or experience. As a Xamarin veteran, I get why they do this. I feel that unless there is a significant team increase, Xamarin needs to focus and redirect existing effort towards developer productivity, meaning less IDE bugs and faster development cycle.

Example
.
Here is an unabridged example of a simple registration code page in a production app I wrote:

Content = new Grid { 
    RowSpacing = 0, 
    RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition {}},
    Children = {
        PageHeader.Create(PageMarginSize, nameof(vm.RegistrationTitle), returnToPreviousViewCommandPropertyName: nameof(vm.CancelEnterRegistrationCodeCommand), centerTitle:true),

        new ScrollView { Content = new Grid {
            RowDefinitions = {
                new RowDefinition { Height = 170 },

                new RowDefinition { Height = 75 },
                new RowDefinition { Height = GridLength.Auto },
                new RowDefinition { Height = GridLength.Auto }
            },
            RowSpacing = 0,

            ColumnDefinitions = {
                new ColumnDefinition { Width = 160 },
                new ColumnDefinition { }
            },

            Children = {
                new Label {
                    Margin = fieldNameMargin, LineBreakMode = LineBreakMode.WordWrap, 
                    HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, 
                }.SetFontSize(WspFontSizes.Size15)
                 .SetColRow(0, 2, 0, 1)
                 .Bind(nameof(vm.RegistrationPrompt)),

                new Label { Text = "Registration code", VerticalOptions = LayoutOptions.End, Margin = fieldNameMargin }.SetFontSize(WspFontSizes.Size13)
                .SetColRow(0, 1, 1, 2),
                new Label { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.End, Margin = fieldNameMargin }.SetFontSize(WspFontSizes.Size13)
                .SetColRow(1, 2, 1, 2)
                .Bind(nameof(vm.RegistrationCodeValidationMessage)),

                new Entry {
                    Placeholder = "E.g. 123456", HeightRequest = 44, Keyboard = Keyboard.Numeric, 
                    BackgroundColor = WspColors.White.ToColor(), TextColor = WspColors.Gray1.ToColor(), Margin = fieldMargin }.SetFontSize(WspFontSizes.Size15)
                .Bind(nameof(vm.RegistrationCode), BindingMode.TwoWay)
                .Id(AId.RegistrationCodePage_CodeEntry)
                .SetColRow(0, 2, 2, 3),

                new Button {
                    Text = "Verify",
                    Margin = PageMarginSize,
                    HeightRequest = 44,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    TextColor = WspColors.White.ToColor(),
                    BackgroundColor = WspColors.ColorValueAccent.ToColor()
                }.SetFontSize(WspFontSizes.Size13)
                 .Id(AId.RegistrationCodePage_VerifyCodeButton)
                 .Bind(Button.IsVisibleProperty, nameof(vm.CanVerifyRegistrationCode))
                 .Bind(nameof(vm.VerifyRegistrationCodeCommand))
                 .SetColRow(0, 2, 3, 4),
            }
        }}.SetColRow(0, 1)
     }
 };

Nothing advanced is going on here, I use standard C# language features to reuse controls (e.g. PageHeader.Create method ) and to simplify data binding (.Bind extension methods). In my eyes the above reads similar to equivalent XAML.

Which is not very surprising given that XAML is at its heart just an object serialization format in XML. In other words, XAML does what the new keyword in C# does.

Now, C# is designed for humans; while XML is better for tools such as visual designers. As a matter of fact, that was the vision for (WPF) XAML: that human designers could use a tool (Blend) to create a UI that developers could consume. However, I experienced how that vision, even in the best possible time and scenario, failed to deliver (I Built a WPF app for Windows tablet together with a XAML book authoring, leading designer, who was a master in Blend, when that was THE tool. The UI was beautiful and totally unmaintainable). So even if there would come an ultimate visual designer tool for Xamarin Forms, equivalent to the best that Blend ever was, it would still fail for the same reasons. Time to move on, like Flutter?

So, anyone (Xamarin devs and Xamarin team) wants to chime in on either XAML versus C# or redirecting Xamarin IDE efforts?
I'm really curious how Xamarin devs (especially experienced ones) see this.

Thanks!

Apk deployment doesn't include last code-modifications

$
0
0

Hello,
In a xamarin-forms I've made some modifications to the code, to forms and to the version number in the proprerties of the project.
When I make the apk, the new version number is taken, but when I deploy the new apk, the forms
are still in an old version.

during debuggin via usb, the modifications are taken.

  • I've uninstalled the apk, db etc from the smartphone.
  • I've deleted the bin/obj, cleaned the project, deleted the appdata/xamarin
  • I tried also on a other clean smartphone but the result is the same.

Have You same ideas?
Thanks very much

Microsoft Visual Studio Community 2017 Versione 15.9.4 VisualStudio.15.Release/15.9.4+28307.222
Microsoft .NET Framework Versione 4.7.03056
Edizione installata: Community
ADL Tools Service Provider 1.0
Gestione pacchetti NuGet 4.6.0
Microsoft JVM Debugger 1.0
Microsoft MI-Based Debugger 1.0
Microsoft Visual Studio Tools per contenitori 1.1
MLGen Package Extension 1.0
Mono Debugging for Visual Studio 4.13.12-pre (9bc9548)
MySQL for Visual Studio 1.2.8
Pacchetto di Microsoft Visual Studio VC 1.0
Pacchetto di Strumenti Application Insights per Visual Studio 8.14.11009.1
Pacchetto host dell'adattatore di debug di Visual Studio Code 1.0
ProjectServicesPackage Extension 1.0
Servizio di linguaggio JavaScript 2.0
SQL Server Data Tools 15.1.61810.11040
SQLite & SQL Server Compact Toolbox 4.7
Strumenti C# 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
Componenti di C# usati nell'IDE. A seconda delle impostazioni e del tipo di progetto, potrebbe essere usata una versione diversa del compilatore.
Strumenti comuni di Azure 1.10
Strumenti di Microsoft Azure 2.9
Strumenti di Microsoft Azure Service Fabric per Visual Studio 2.4
Strumenti di recapito continuo Microsoft per Visual Studio 0.4
Strumenti di Workflow Manager 1.0 1.0
Strumenti TypeScript 15.9.20918.2001
Strumenti Visual Basic 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
ToolWindowHostedEditor 1.0
Visual Studio Tools per app di Windows universale 15.0.28307.208
Visual Studio Tools per contenitori 1.0
Visual Studio Tools per Unity 3.9.0.3
VisualStudio.Mac 1.0
Xamarin 4.12.3.77 (d15-9@e3f40b477)
Xamarin Designer 4.16.13 (45a16efd4)
Xamarin Templates 1.1.128 (6f5ebb2)
Xamarin.Android SDK 9.1.4.2 (HEAD/8255f42fc)
Xamarin.iOS and Xamarin.Mac SDK 12.2.1.12 (65ec520)

Style the Child

$
0
0

Hello,

I have the next example:

  <StackLayout Padding="16" Spacing="16">
                                    <Label Text="{Binding Title}" FontAttributes="Bold" />
                                    <BoxView Color="Gray" HeightRequest="1" />
                                    <Label Text="{Binding SubTitle}">

</StackLayout>

Like can I do so that it does not affect padding BoxView?

Viewing all 91519 articles
Browse latest View live


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