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

Pressing buttons multiple times loads multiple pages (Android)

$
0
0

I'm having an issue with Android navigation. I have a list view that contains a bunch of items that have tapped events. These tapped events look like this:

    async void Tab_ItemSelected(object sender, ItemSelectedEventArgs e)
    {
        var details = new DetailPage(e.SelectedItem.ID);
        await Navigation.PushAsync(details);
    }

This works on iOS and Windows Phone just fine, but if you're quick enough, it will load two detail pages onto the stack. This also seems to occur quite a few places on our Android application. Is there any way around this?


Xamarin.Forms.RowDefinition cannot be converted to target type: Xamarin.Forms.RowDefinion

$
0
0

I keep getting the above exception when trying to run the android version of my app. it is occurring on the following line in mainviwe.xaml.g.cs
public partial class MainView : global::XLabs.Mvvm.Views.BaseView {

    private void InitializeComponent() {
        this.LoadFromXaml(typeof(MainView)); // here
    }

WP8 works ok.

im using 1.2.3.6257 of xamarin.forms, VS2013.

TabbedPage Error when Icon is set.

$
0
0

Hello,
When Icon property is set for a tabbedpage like:

it gets an error:

System.Exception: Could not initialize an instance of the type 'UIKit.UIImage': the native 'initWithContentsOfFile:' method returned nil.

It is possible to ignore this condition by setting MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.

....

already checked if icons were in the Resources folder inside ios project with properties to BundledResources but still getting the same error.

Do I missing something?
Regards,
Jun

Why is idle HEAP always the same size regardless of maximum available?

$
0
0

After checking my app on multiple Android devices, I've noticed something odd with respect to he available heap space.
One device might have a max of 256. Another a max of 512. If I don't set largeheap to true then it will be 128.
Yet regardless the size of the heap the AVAILABLE heap is always 15mb when idle.
This is not a static value. I can see it rise and fall with work being done. The available being returned seems accurate because if I don't take precautions when scanning and drive it down to <2mb then it will throw an OOM exception stating it tried to allocate 3mb with only 1.4 available-and the amount the exception said was available matches my calculated amount.

So that's where I am confused. How does the same app which presumably has the same base footprint never get more available heap regardless of largeheap or device? More importantly - How can I use that available heap? Its silly that I'm going OOM when I have 512 total and not using any of it.

I tend to beleive these calculations are right because they change correctly when I change devices or turn of LargeHeap; but I'll provide them anyway in case someone knows a better way.

//This is running from the Droid project and returning the value to the PCL

        /// <summary>Return in MB
        ///
        /// </summary>
        /// <returns></returns>
        public override decimal GetTotalHeap()
        {
            Java.Lang.Runtime runtime = Java.Lang.Runtime.GetRuntime();
            long maxHeapSizeInMB = runtime.MaxMemory() / 1048576L;
            return maxHeapSizeInMB;
        }

        public override decimal GetAvailHeap()
        {
            Java.Lang.Runtime runtime = Java.Lang.Runtime.GetRuntime();
            var aval = runtime.FreeMemory();
            return aval / 1048576L;
        }

Why is RowDefinitions not working on WindowsPhone but works on WindowsPhone emulator?

$
0
0

Why is RowDefinitions not working on WindowsPhone but works on WindowsPhone emulator? It also works on any android or IOS

the xaml looks something like this:

<Grid
                RowSpacing="0"
                ColumnSpacing="0">
                <Grid.RowDefinitions>
                  <RowDefinition Height="20" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="20" />
                  <RowDefinition Height="*" />
                  <RowDefinition Height="20" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="20" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="20" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="20" />
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="20" />
                </Grid.ColumnDefinitions>

Its on the content page and the error is:
Message = "Object of type 'Xamarin.Forms.RowDefinition' cannot be converted to type 'Xamarin.Forms.View'."

Custom listview grouping

$
0
0

Hello!
I have problem with understanding grouping in listview. I have such class

class BaseActionModel
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get { return _id; } set { _id = value; } }
        public double Value { get { return _value; } set { _value = value; } }
        public DateTime Time { get { return _time; } set { _time = value; } }
        public string TextColor { get { return _textColor; } set { _textColor = value; } }
    }

I have binded this list to xaml as ObservableCollection and it works.
Now I would like to create custom groping like here in middle image - create proper time interval (eg. "Today", "Yesterday", "This week".. and so) and classify observation to right group due to its Time value.

How could I achieve it? It is important to make this dynamic - new observations will be added very often and it is needed that group of observation will be calculated in runtime.

Thanks in advance for your tips.

Modal View does not get page OnAppearing/OnDisappearing

$
0
0

Hey there friends,
I converted one of my pages to a ModalPage.

I open it with
await _navigation.PushModalAsync(target, ShowAnimations);

and close with
await _navigation.PopModalAsync(ShowAnimations);

The interesting thing here is that if I send app to BG while this modal page is being show, the events OnAppearing/OnDisappearing goes to the previos page, that opened the modal page, and not to the modal page.

is this "by design" or a bug?

I was expecting the events to keep going to the "right" page, am I wrong?

Thanks,
NighOwl

Views Creation in Runtime - XAML

$
0
0

Hi All,

I have some components/views I defined in XF XAML that meant only for android. At the same time I have others for iOS only. I try to control them through IsVisible property using OnPlatform tag like this:

But since it manipulates the visibility only, this mean it will be created and will live in memory forever even in undesired platform with visibility is off. Please correct me if I am wrong. I am still new in XF world.

Do we have any alternatives in XAML way? In code behind approach, I know how to do it but I am interesting about XAML way.

-K


How to dismiss display alert when session timeout

$
0
0

I opened display alert in xamarin forms application and kept application idle for 15 min and application time out and takes the user to login page but still display alert is displaying on top of login page. How to dismiss display alert when application times out?

Anyone know how to remove the blue line under Android ListView Group Headers?

$
0
0

Hi, has anyone successfully managed to remove the thin blue line under the Android Listview Group Headers?
I've tried a number of approaches, nothing appears to work, any help would really be appreciated.
Tx

XamlParseException Xamarin Forms

$
0
0

I got this error by trying to put an Method on a Button click Event
How Am I supposed to fix this? I saw many Thread About this telling me it's my Linker Options, but the linker option is "Ok", it was None by default and didn't worked.

Error

Here is My Project

Linker

XAML Home Page

Code Behind

How do I remove the divider line of the TableSectionHeader in Android?

$
0
0

Hello,

In Android I have 3 TableSections.
Every TableSection has a TableSectionHeader with a divider line.
I have the following custom renderer which hides the header, but I cannot remove the divider line.
See also the attachment, the blue lines.

//Used to clear empty headers in TableView for sections without a specified title********
[assembly: ExportRenderer (typeof(TextCell), typeof(TableSectionHeaderRenderer))]
public class TableSectionHeaderRenderer : TextCellRenderer
{
protected override Android.Views.View GetCellCore (Cell item, Android.Views.View convertView, ViewGroup parent, Context context)
{
// Hide cells of TableSections with no title.
var view = base.GetCellCore (item, convertView, parent, context) as ViewGroup;
if (String.IsNullOrEmpty ((item as TextCell).Text)) {
view.Visibility = ViewStates.Gone;
while (view.ChildCount > 0) {
view.RemoveViewAt (0);
}
view.SetMinimumHeight (0);
view.SetPadding (0, 0, 0, 0);
}
var textCell = (TextCell)item;
return view;
}
}

How can I add a ToolbarItem to a non-root Navigation Page in Xamarin.Forms?

$
0
0

Hi!

On App.xaml.cs, I call the main page using:

MainPage = new NavigationPage(new MainPage());

On MainPage.xaml, the ToolbarItems is working as expected, using the following code:

<ContentPage.ToolbarItems>
    <ToolbarItem Name="Menu1" Order="Secondary" />
    <ToolbarItem Name="Menu2" Order="Secondary" />
    <ToolbarItem Name="Menu3" Order="Secondary" />
    <ToolbarItem Name="Menu4" Order="Secondary" />
</ContentPage.ToolbarItems>

When I call another page from MainPage.xaml.cs using the following code:

await Navigation.PushAsync(new ManageServices());

and add the following code to ManageServices.xaml, the ToolbarItems does not appear.

<ContentPage.ToolbarItems>
    <ToolbarItem Name="Menu1" Order="Secondary" />
    <ToolbarItem Name="Menu2" Order="Secondary" />
    <ToolbarItem Name="Menu3" Order="Secondary" />
    <ToolbarItem Name="Menu4" Order="Secondary" />
</ContentPage.ToolbarItems>

I need to maintain the navigation stack (MainPage > ManageServices) so the user can navigate back from ManageServices to MainPage, and at the same time, have a different context menu in ManageServices using ToolbarItem.

How can I do that?

Thank you!

Signature Pad for Xamarin.Forms

Android keyboard and the ContentPage view collapsing/expanding issue w/ Material Design

$
0
0

Hi, after I upgraded to 1.5.1 and getting material design in place, my app is working and looking great in Android. HOWEVER the view when focussing or unfoccusing the keyboard does not work as expected.

I have a Grid with icons at the bottom of my ContentPage. So when the keyboard expands the Grid should be sitting on top of the keyboard and the Editor shrinking in height to accomodate. As mentioned this worked before the Material Design update.

I am using the IosKeyboardFixPageRenderer from http://stackoverflow.com/questions/31172518/how-do-i-keep-the-keyboard-from-covering-my-ui-instead-of-resizing-it/31172519 for iOS and it works great.

How do I fix this on Android with Material Design?

Thank you


Xamarin.Forms Feature Roadmap

$
0
0

This roadmap outlines our anticipated feature releases.

Are there things you don't see here that you feel strongly deserve a spot? Make your voice heard and open a proposal on the Xamarin.Forms Evolution forum.

Primary Focus

Quality is top of the list. This means stability and performance first and foremost. Xamarin.Forms has been swiftly adopted as a preferred tool for delivering production apps in addition to rapid prototypes. Our focus and priorities are to support the Xamarin.Forms community in those areas. In the release schedule below, we've highlighted how and where we are making those investments.

A Note About Bugs

As this thread is primarily about the feature roadmap, we anticipate the important question "what about ___ bug"?! Improving quality by addressing bugs is huge priority and ongoing focus for the team, in addition to improve our communication across the board.

Disclaimer

We cannot predict the future and how everything will shake out. Things will change. Timing may be adjusted due to priority changes, in pursuit of quality standards, or any number of other really good reasons that we will strive to proactively and openly communicate.

The Features Roadmap

Milestone Release Date
2.3.3 December 2016
2.4.0 February 2017
2.5.0 May 2017

2.3.3 - December 2016

Native View Declaration - Feature
Native view declaration allows you to add bindable iOS, Android, and Windows views directly to XAML. Rather than having to write a custom renderer, you can simply add the control directly to XAML with no additional configuration. This not only works with stock platform controls, but custom controls as well.

Platform-Specifics - Feature
Platform-specifics allow you to take advantage of native functionality that is only available on select platforms that Xamarin.Forms targets from shared code.

UWP Blur Support (3rd party nuget) - Feature
Adds the UWP blur platform-specific.

2.4.0 - February 2017

Bindable Picker - Feature
Adds data binding to the Picker control, specifically the following properties:

  • ItemSource

  • SelectedItem

https://github.com/xamarin/Xamarin.Forms/pull/515

Accessibility (A11y) Support - Feature
Proposal
Adds accessibility support to Xamarin.Forms by exposing the underlying accessibility features on iOS, Android, and Windows 10.

CarouselView v1 Stable - Feature
CarouselView was introduced at Xamarin Evolve 2016 and has been in prerelease ever since. v1 brings stability and performance improvements.

Xamarin.Forms for macOS Preview - Feature
Xamarin.Forms is coming to macOS, joining iOS, Android, Windows, and Tizen as target platforms for Xamarin.Forms.

Fast Renderers - Performance
Optimize built-in and custom view renderers to streamline view creation and improve performance.

Startup Time Improvements - Performance
Improve the startup and initialization time for Xamarin.Forms apps.

Compiled Native Views - Enhancement, Performance
Bring native view declaration to XAMLC, so users don't have to opt-out of XAMLC in PCLs where pages use native view declaration.

OnIdiom Support for Desktop (UWP) - Enhancement
Developers have lots of options when it comes to configurability based on operating system (Android, iOS, UWP, etc.), version (9, 10, etc.), and idiom (mobile or tablet). This adds Desktop as an OnIdiom for UWP developers.

https://github.com/xamarin/Xamarin.Forms/pull/420

XAMLC Enhancements - Enhancement, Performance
Approaching full support for currently supported XAML features. Compile time support for all value providers.

Deprecation of iOS 6/7

Deprecation of WP8

2.5.0 - May 2017

Xamarin.Forms Embedding - Feature
Embed Xamarin.Forms into a native Xamarin.iOS, Xamarin.Android, or Windows 10 app.

Xamarin.Forms for macOS - Feature
Xamarin.Forms is coming to macOS, joining iOS, Android, Windows, and Tizen as target platforms for Xamarin.Forms.

MenuPage - Feature
Alternative to the MasterDetail page, but rendered as a platform-specific menu that makes creating flyouts easy.

Cut down on GPU overdraw for Android - Performance
Try to avoid overdraw on Android where possible to improve performance.

Reduce native views created - Performance
Cut down on backing native views created for Xamarin.Forms, as noted by Miguel in #42948.

Layout Compression - Performance
LayoutCompression allows multiple layers of Xamarin.Forms layouts to be packed into a single native one.

Prism-Like URI Navigation Routing - Enhancement
Navigate to a page using Uri navigation, similar to what Prism does.

NavigationService.NavigateAsync("ListPage/DetailPage?id=1");

Single DLL - Enhancement
Ship Xamarin.Forms as a single DLL to improve startup performance and assist the linker.

Open Source Contributions

As noted above, the Xamarin.Forms Evolution forum is the place to start.

App crashing on Windows Phone when deplyed in Release mode

$
0
0

Hi,

We have developed a Xamarin Forms app supporting Android, iOS and Windows Phone. The app is working on all three OS when deployed in Debug mode. It's also working on Android and iOS when deployed in Release mode. It crashes immediately after displaying Splash screen on Windows Phone 8.1/10 when deployed with Release mode but strangely all works fine when deployed using Debug mode.

Any idea from experts here?
Is there any way to get see the app log to diagnose the crash reason?

Thank you,
Deepak Sakpal

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>

Xamarin Forms - Webview - Remote Website - Load included javascript file

$
0
0

I have a simple Xamarin Forms project that has a WebView which is used to load an ASP.NET website on our intranet. Currently there is only a Android implementation in the solution.

The website being loaded includes several CSS and Javascript files. The CSS files are being linked via link rel tags, while the Javascript files are linked using script src tags.

I have put alert statements in a script on the page itself, as well as in the linked Javascript file. Using a browser on my computer, both alert statements show up, however in the WebView, only the alert for the page shows up.

I've also tried using the WebView.eval method to call a Javascript method in the linked file as well as one defined on the page itself. Calling the method defined on the page worked, but the one in the linked Javascript file didn't.

All that has lead me to the conclusion that for some reason the WebView isn't loading the Javascript files indicated by the script src tags.

From research I have done, there is mention of having to include the Javascript file itself in the Android and iOS projects, but those seemed to be for situations where the WebView source was being set to a constructed website, not pointing to an existing web site.

Here are samples of how the files are linked:
<link rel="stylesheet" href="/App_Themes/wms.min.css" />
<script src="/Scripts/wms.js">

I have tried using absolute paths, which didn't work either:
<script src="http://path.to.site/Scripts/wms.js">

What am I doing wrong? How do I get the the linked javascript files to load and be usable?

PRISM: Display page only after navigation parameters initialize viewmodel data

$
0
0

When navigating from one page to another, I pass data as navigation parameters, but it takes a second or two before the data and the UI are built on the new page. So what I get is a blank content page that displays UI eventually. What I want to do is to display the page in its final state. Without MVVM, I can pass data to the page constructor and build the page from there. I believe in MVVM, navigation pattern is encouraged. How do I solve this problem?

I might show some kind of loading indicator, but I'm wondering if there is a better way because the loading indicator seems like overkill for such a short waiting period. @BrianLagunas

Viewing all 91519 articles
Browse latest View live