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

Are there any Good Examples of a list view with as Sublist using data from web API?

$
0
0

Are there any Good Examples of a list view with as Sub-list using data from web API?

I all,

Would anyone know if there is an example of how one would created a sub-list with in a list view
using data returned from a web Api.

I have seen some example videos but the data is typed it.. they don't show how one would do this with database data
as well as how you would relate the data of the parent list to the child..

Most of the examples I have seen have been users hard coding data.

THanks for any help in advance.


How to select multiple images from gallery for android and IOS device and how to show it in the UI?

$
0
0

Same thread found here. But the answer is not complete.

Android part multiple image selection is working with that code, but didn't tell how to show the selected images in UI?

For IOS suggesting to install ELCImagePicker, but that Nuget is not available in Nuget store.

So anybody please suggest a solution for this feature?

TableSection Spacing Android

$
0
0

Hi
I have 1 TableView, 3 TableSections.
In iOS , the TableSections have a space between them, this space is not replicated in Android, how would I add the space in Android? without upsetting the iOS layout.

My Ideas:

  1. Add a blank, disabled Cell which only shows on Android.
  2. Use a grid, which only shows on Android
  3. Platform Specific XAML forms, if == Android, use XAML-A if ==iOS use XAML-B
  4. Custom renderer. If so, How?

I am open to other ideas or if someone could tell me the recommended way or, which of my ideas to pursue it would be much appreciated.

MvvmCross MvxTabbedPage documentation?

$
0
0

I'm trying to find documentation on the MvvmCross MvxTabbedPage. I can't find it in the MvvmCross documentation or GitHub repo - hopefully I'm just not looking in the right place!

Specifically, where (if possible) I can adjust the layout of the tab items - e.g. the font style and icon size used in the tabs.

Can someone point me in the right direction please?

Error message:Project Android.Common is not compatible with netstandard2.0

$
0
0

In my project I have a strange error message:
Project Android.Common is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project Android.Common supports: monoandroid81 (MonoAndroid,Version=v8.1)
I use Visual Studio 15.9.5 and Xamarin.Forms 3.4.0.1009999 in the project
I don't have any idea how I can resolve.

Any ideas ?

Manipulate image for ListView

$
0
0

Hello
I've got a problem. I want to have some kind of dynamic icon for my ListView items. Means: I want to create that icon programatically at runtime.

Therefore I need the following:
1. Load an ong from file
2. place text on that file
3. place another png-symbol in a specific area of that image
4. save that image to disk
5. path to imagesource

Sounds easy, but seems to be not as easy at Xamarin, is it?

How delete past events of a page when leaving it with PopAsync ?

$
0
0

Hi everybody,
I call MyPage with Navigation.PushAsync() from the MainPage. I have next code in MyPage's constructor:

    public MyPage(IAdapter adapterin, IDevice devicein, string ChannelName)
    {
        InitializeComponent();
        adapter = adapterin;
        device = devicein;
        LabelChannelName.Text = ChannelName;

        adapter.DeviceConnectionLost += (s, e) =>
        {
            Debug.WriteLine($"LOST CONNECTION: {e.Device.Name}");
            adapter.DeviceConnectionLost -= null;
            Device.BeginInvokeOnMainThread(() =>
            {
                this.Navigation.PopAsync();
            });
            Debug.WriteLine($"LOST CONNECTION.");
        };
    }

When adapter.DeviceConnectionLost happens (for instance when I shut dowm my ble peripheral) MyPage closes correctly.
The second time I open MyPage if DeviceConnectionLost event happens then I get an Unhandled Exception, cause I guess PopAsync is reached twice. It seems that second PopAsync() generates the exception.

I have checked that if MyPage is loaded three times for example, ConnectionLost event will be executed three times, as I can see "LOST CONNECTION." text in my debug output window.

Is there any way to erase past events of MyPage after doing PopAsync ? How could I resolve this issue ?

Thanks in advance and best regards,
Asier.

How to solve System.FormatException: Index (zero based) must be greater than or equal to zero

$
0
0



above is my code .Why i am getting Exception(System.FormatException:) .Please any one suggest?


How can I change an Image Border color on hover in Xamarin?

$
0
0

I need to change an image's border color on hover and remove the border when the hover is removed. Is there a way to do this in Xamarin?

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!

How to Implement webView Rendering and pass data in UWP ?

$
0
0

Can any one suggest me how to implement webview Rendering in UWP xamarin.forms .
Thanks in Advance.

Error Native linking error: framework not found

$
0
0

Native linking error: framework not found FoxitRDK.
How to solve this Error.

TabbedPage switch page performance problem

$
0
0

Hello,

I have a tabbedpage and i have "randoms lags" when i switch page. My tabbedpage itemsource is binding with an IGrouping<int,MyClass>>.
Each page got a calendar.

Anyone got an idea?

Best regards

Debug infos after 2 consecutives switch move:

02-21 15:20:05.479 I/art     (11401): Explicit concurrent mark sweep GC freed 3361(161KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 14MB/23MB, paused 960us total 48.639ms
02-21 15:20:05.499 D/Mono    (11401): GC_TAR_BRIDGE bridges 4 objects 634316 colors 4 ignored 381990 sccs 4 xref 0 cache 0/0 setup 0.35ms tarjan 737.16ms scc-setup 0.03ms gather-xref 0.00ms xref-setup 0.00ms cleanup 21.43ms
02-21 15:20:05.499 D/Mono    (11401): GC_BRIDGE: Complete, was running for 78.65ms
02-21 15:20:05.499 D/Mono    (11401): GC_MINOR: (Nursery full) time 825.87ms, stw 826.16ms promoted 42K major size: 33648K in use: 32056K los size: 3072K in use: 1610K
02-21 15:20:05.509 I/Choreographer(11401): Skipped 53 frames!  The application may be doing too much work on its main thread.
02-21 15:20:05.549 D/ViewRootImpl(11401): ViewPostImeInputStage ACTION_DOWN
02-21 15:20:06.169 D/ViewRootImpl(11401): ViewPostImeInputStage ACTION_DOWN
02-21 15:20:06.229 W/ResourceType(11401): Failure getting entry for 0x01080ad1 (t=7 e=2769) (error -75)
02-21 15:20:06.229 W/ResourceType(11401): Failure getting entry for 0x01080ad1 (t=7 e=2769) (error -75)
02-21 15:20:06.229 D/AbsListView(11401): Get MotionRecognitionManager
02-21 15:20:06.239 W/FragmentManager(11401): moveToState: Fragment state for FragmentContainer{2ebfe03f #3 id=0x4 android:switcher:4:537017682} not updated inline; expected state 3 found 2
02-21 15:20:06.839 I/Choreographer(11401): Skipped 35 frames!  The application may be doing too much work on its main thread.
02-21 15:20:10.999 D/Mono    (11401): [0x9288ef80] hill climbing, change max number of threads 19
02-21 15:20:27.859 D/Mono    (11401): [0x9288e300] hill climbing, change max number of threads 5
02-21 15:20:36.889 D/Mono    (11401): [0x9288e300] hill climbing, change max number of threads 4
02-21 15:20:50.079 D/Mono    (11401): [0x91e2ea80] hill climbing, change max number of threads 24
02-21 15:20:51.669 I/art     (11401): Explicit concurrent mark sweep GC freed 3368(167KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 14MB/24MB, paused 969us total 53.228ms
02-21 15:20:51.709 D/Mono    (11401): GC_TAR_BRIDGE bridges 77 objects 638730 colors 77 ignored 382541 sccs 77 xref 0 cache 0/0 setup 0.22ms tarjan 750.92ms scc-setup 0.21ms gather-xref 0.01ms xref-setup 0.00ms cleanup 32.65ms
02-21 15:20:51.709 D/Mono    (11401): GC_BRIDGE: Complete, was running for 91.00ms
02-21 15:20:51.709 D/Mono    (11401): GC_MINOR: (Nursery full) time 847.76ms, stw 848.09ms promoted 323K major size: 34016K in use: 32411K los size: 3072K in use: 1689K
Thread finished: <Thread Pool> #19
02-21 15:20:51.729 I/Choreographer(11401): Skipped 56 frames!  The application may be doing too much work on its main thread.
Le thread 'Unknown' (0x13) s'est arrêté avec le code 0 (0x0).
Thread started: <Thread Pool> #20

Simple Cross Platform App - Getting Started

$
0
0

Hi
I have done a lot of reading and youtube tutorials and I think I am ready to start, but need some direction please.
Project is a simple app for iPhone at this stage that takes a photo or video and allows the user to discard/use, if use then add some free text, select info from some pick lists, records the location (GPS) then uploads to my Wordpress website.
The UX would be the same as listing something on Gumtree, (but its not commercial).
I will be using Visual Studio 2017 community ed.
Restrictions are; user cannot add photo from library, it has to be what was just captured (web audience has to be assured footage not tampered with).
Can anyone direct me to a template of sample that does this, or gets me started please?
Have I come to the right place?
Thanks
Tim

how to get week value on DatePicker Selected xamarin forms

$
0
0

I want to select the DatePicke to return the week of the selected date


Bind ContextAction command from MenuItem to ViewModel

$
0
0

Greetings everyone,
I'm not able to pass data from my ListView Item ContextAction, I'm setting the XAML parameters right? Here is the code:

XAML:~~~~

                            <ViewCell.ContextActions>
                                <MenuItem
                                    Command="{Binding SharePlaceCommand}"
                                    CommandParameter="{Binding .}"
                                    Text="Compartilhar" />
                                <MenuItem
                                    Command="{Binding EditPlaceCommand}"
                                    CommandParameter="{Binding .}"
                                    Text="Editar" />
                                <MenuItem
                                    Command="{Binding DeletePlaceCommand}"
                                    CommandParameter="{Binding .}"
                                    IsDestructive="True"
                                    Text="Deletar" />
                            </ViewCell.ContextActions>

In VM:

    private ObservableCollection<PlacesBD> _placesList;
    public ObservableCollection<PlacesBD> PlacesList { get { return _placesList; } set { _placesList = value; OnPropertyChanged("PlacesList"); } }

    public ICommand SharePlaceCommand { get; set; }
    public ICommand EditPlaceCommand { get; set; }

    this.SharePlaceCommand = new Command<PlacesBD>(SharePlace);
    this.EditPlaceCommand = new Command<PlacesBD>(EditPlace);

    private async void SharePlace(PlacesBD place)
    {
        Debug.WriteLine(@"      SharePlace  {0}",place);
    }

    private async void EditPlace(PlacesBD place)
    {
        Debug.WriteLine(@"      EditPlace   {0}", place);
    }

How to access content (not embedded) images on Android / UWP

$
0
0

It really sucks! I just want to open the ditributed files, but I don't get it.
First of all I cannot get the correct paths to the files (drawable on Android and assemby/../ on UWP)

Thus.

1 (Android and UWP: How these files can be accessed. What's the best way to get the filepaths?
2. UWP: How do I obtain a StorageFile object from a file string path? (I need an IRandomAccessStream from that image files on UWP)?

Navigating and passing parameter to a TabbedPage child view's ViewModel in MVVM

$
0
0

What would be MVVM way of passing a parameter to the initial View's ViewModel, which is loaded into the detail area when navigating to the TabbedPage?

An example use case could be that I'm located in orders view, and click on one of the orders, it navigates me to the tabbed page that has order details view as the first tab. How do I pass the order details to the OrderDetailsViewModel? When using TabbedPage I have an additional layer in between. In my mind, the order details would have to be passed in a similar flow to this: OrdersViewModel ->TabbedPageViewModel -> OrderDetailsViewModel.

Is something like MessagingCenter viable solution for this type of communication?

I don't use MVVM Framework, but I wonder how would a frameworks like MvvmCross, Prism, MVVM Light would handle this scenario?

DataTrigger work with Converter seems have BUG!!!

$
0
0

Requirement Description:

I'd like to change the source of a image by using "Data Trigger" , but when I use it with "Converter" , it doesn't work as expected.

Code:

CustomImage

public class CustomImage : Image
    {

        public CustomImage()
        {
            PropertyChanged += OnPropertyChanged;
        }

        private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Source")
            {
                var fileSource = (Source as FileImageSource);
            }
        }
    }

Converter

public class IconSourceConverter : IValueConverter
{

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (parameter != null)
        {
            string par = parameter as string;
            if (par == "Selected")
            {
                return "image_one.png";
            }
            else
            {
                return "image_one_selected.png";
            }
        }
        else
        {
            return "image_one.png";
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotSupportedException();
    }

    private enum ConverterParameter
    {
        NoSelected, Selected

    }
}

XamlCodeOne:

<control:CustomImage  WidthRequest="16"   >
                <control:CustomImage.Triggers>

                    <DataTrigger TargetType="control:CustomImage" Binding="{Binding IsVisible}" Value="False">
                   <Setter Property="Source" Value="{Binding PageType, Converter={StaticResource PageTypeToIconSource} , ConverterParameter='Selected' }" />
                    </DataTrigger>

                    <DataTrigger TargetType="control:CustomImage" Binding="{Binding IsVisible}" Value="True">
                                      <Setter Property="Source" Value="{Binding PageType, Converter={StaticResource PageTypeToIconSource} , ConverterParameter='NoSelected' }" />
                    </DataTrigger>

                </control:CustomImage.Triggers>
            </control:CustomImage>

XamlCodeTwo:

    <control:CustomImage  WidthRequest="16"   >
                    <control:CustomImage.Triggers>

                        <DataTrigger TargetType="control:CustomImage" Binding="{Binding IsVisible}" Value="False">
                            <Setter Property="Source" Value="image_one.png" />
                        </DataTrigger>

                        <DataTrigger TargetType="control:CustomImage" Binding="{Binding IsVisible}" Value="True">
                            <Setter Property="Source" Value="image_one_selected.png" />
                        </DataTrigger>

                    </control:CustomImage.Triggers>
                </control:CustomImage>

Result:

When I use XamlCodeTwo , it works well . But when I use XamlCodeOne , it doesn't work as expected and it toggles "OnPropertyChanged"(in CustomImage) several times . As I know , it should only be toggled when the value of DataTrigger change.

Question:

Why I use XamlCodeOne can not work and why it toggles "OnPropertyChanged" (in CustomImage) several times?

How can I refresh a page?

$
0
0

Greetings, I am starting in xamarin forms and I have the following problem
I have two pages page1 and page2 of type NavigationPage, on page1 I show a series of data and information to the user and I can go with a button to page2 which is a kind of form that the user can fill out but when filling in some fields on page1 they should be updated the doubt is the following how can I refresh the page1 from page2? , on page1 I have a function that refreshes the fields that I want to update by printing these changes on the screen. Is it possible to call that function from page2? I try to do the static function but I get an error in the elements of the xaml on page1 that I want to change
Another question I have is why, if I surf, do I have a lot of navigation from page1 to page2 and vice versa does the app end?
to go from page1 to page2 use:
await ((NavigationPage) this.Parent) .PushAsync (new Page2 ());

and to go from page2 to page1 use:
await ((NavigationPage) this.Parent) .PushAsync (new Page1 ());

Viewing all 91519 articles
Browse latest View live


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