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

Displaying a ContentView inside a ContentPage with a button click?

$
0
0

Hello all, I'll explain what I'm trying to do. I have a ContentPage (RecipePage) displaying a list of items, a searchbar and some buttons. I'd like to set up a long list of filters that the user can use to narrow down their search, and I have that as a ContentView (FilterPage) on a separate xaml file. I'd like to be able to click a button to display FilterPage while staying on RecipePage, and then another button to hide/remove the FilterPage instance once the user's done with the filters.

The project has also a master page consisting of a navbar with a single button that displays a menu, which is using the MasterBehaviour = "Popover" property. I'd like to imitate the slide-in/out visual effect that is created by that property to display the filter view, but MasterBehaviour is naturally only available to MasterDetailPage.

So, to summarize:

  • How can I display a ContentView inside a ContentPage with a button click?
  • Can the MasterBehaviour = "Popover" effect be imitated in some other way to allow the ContentView to slide in/out when the user clicks the button?

Please let me know if anything's unclear, and thank you in advance for your time.


Trying to update packages, getting an error that the package has no compatible assembly references

$
0
0

I recently updated my Xamarin build tools for an older project. I decided to go ahead and try to install the latest package updates as well. When trying to update those packages I get the following error:

Could not install package 'EntityFramework 6.2.0'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v9.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I've tried changing my build target to API 28, 27, 25, and 21 as other posts suggested this helped some people. I've also uninstalled and reinstalled Visual Studio for Mac. This didn't make a difference for me. What else should I look at or try to get this working?

I'm working off of a Mac running the latest version of OSX.

MVVM cascading pickers SelectedItem not firing

$
0
0

Hi. I have two pickers that I want to cascade, i.e., when a user picks a value in the first picker, the second one is populated based on the selected item.

Here's what I have:
XAML:

  <Picker x:Name="C" Title="C" ItemsSource="{Binding Cs}" ItemDisplayBinding="{Binding Value}" SelectedItem="{Binding SelectedC, Mode=TwoWay}" />
  <Picker x:Name="T" Title="T" ItemsSource="{Binding Ts}" SelectedItem="{Binding SelectedT}" />

In View Model class:

public List<KeyValuePair<string, string>> Cs { get; private set; } = new List<KeyValuePair<string, string>>();   // This gets populated in the code behind.

private KeyValuePair<string, string> _SelectedC;
public KeyValuePair<string, string> SelectedC
     {
         get => _SelectedC;
         set
         {
            _SelectedC = value;
             // Update Ts item source.
         }
     }

Problem is SelectedC's setter never fires. Please let me know if you have any ideas. Thanks.

WebView/HybridWebView Context Menu

$
0
0

Is there any way to show the context menu? especially ios.
do you have an idea or sample? can you please share?

Thanks

BaseViewModel, Command holder, Property holder.. experimental

$
0
0

BaseViewModel

If you don't want to use fody and want to save space/time during development (creating private fields) with avoiding contructions like:

        private string _val;
        public string Val
        {
            get => _val;
            set
            {
                if(value == _val)
                {
                    return;
                }
                _val = value;
                OnPropertyChanged();
            }
        }

        private ICommand _command;
        public ICommand Command => _command ?? (_command = new Command(() =>
        {
            //check if it isn't fast double tap..oh... try/cathc etc..
        }));

You can copy and paste two classes https://github.com/AndreiMisiukevich/BaseViewModel/tree/master/Lib/BaseViewModel
Make you view model to inherit BaseViewModel and simplify code above:

        public string Val
        {
            get => Get<string>();
            set => Set(value);
        }

        public ICommand Command => Cmd() ?? RegCmd(() =>
        {
        }, TimeSpan.FromMilliseconds(300), true, ex => {
            //handle exception if you want
        });
        //first param - actionFrequency
        //second param - shouldSuppressExceptions, will be no crash if exception occurs
        //third param - onExceptionAction, if you want to handle exception after suppressing

Very small sample: https://github.com/AndreiMisiukevich/BaseViewModel/tree/master/BaseViewModel.Sample

Link: https://github.com/AndreiMisiukevich/BaseViewModel

I'm not sure, that it is useful and makes sense at all :) experimental

All properties are stored in dictionary.

BottomNavigationView option for TabbedPage on Android

Use BottomNavigationView for Android's TabbedPage for a more unified Tab experience on iOS/Android

$
0
0

Summary

The BottomNavigationView (can't post links yet. Google it) that's available in the Android Support Library is the new and preferred way of using tabs in an Android project. Using BNV will create a better out-of-the-box experience for users wanting to use Xamarin Forms for their app development.

Switching to BNV for Android will allow us to introduce Badges as well which will help in simplify XF developers targeting Android and iOS. UWP as far as I know does not have a concept of badges out-of-the-box for Pivot.

API Changes

We already can specify the Title and the Icon from iOS, but with BNV and the UITabBar we could specify the background color, selected tint color and unselected tint color:

tabbedPage.BackgroundColor = Colors.Gray; // Background for the tab bar
tabbedPage.SelectedTintColor = Colors.Red; // Selected color
tabbedPage.TintColor = Colors.Black; // Default (not-selected) color

We can also add badges for each page in the tabbedpage:

<TabbedPage>
    <ExamplePage Title="Agenda" Icon="ic_agenda" BadgeCount="2" />
</TabbedPage>

BadgeCount will be bindable as well.

Taking it a step further we could introduce platform-specifics for setting Tab-color on specific pages (BNV allows you to do that), as well as badge colors (which works on iOS10+ as well).

Intended use case

Be able to create more modern application for Android that uses the latest best practice from Google itself and also introduce Badges that has been missing. All without using custom renderers or third-party packages.

There might be times where the current implementation of TabbedPage on Android will work best, but I would rather have BottomNavigationView to be the default implementation.

Image is skewing in iPhone plus devices and XS Max devices for LaunchStoryBoard

$
0
0

HI Guy's,

I'm using LaunchStoryBoard for splash screen in my xamarin forms app. I used 2x,3x images even-though image is skewing in Plus devices and XS Max devices.

1) 2x Image Size - 750x1334
3x Image Size - 1242x2688(For XS Max used)
In this case Plus device is effecting
2) 2x Image Size - 750x1334
3x Image Size - 1242x2208(For Plus devices used)
In this case XS Max device is effecting

And also I tried by adding images in Assets also leads to the same.

In Assets I created Imageset and added the 1x,2x.3x images in iPhone Devices section.

Can you please help me with the above problem.
Thanks in advance.


Detect and Open another App on device

$
0
0

Can someone tell me the best approach to accomplishing this for IOS and Android. Code samples or links to related discussions would be most appreciated.

thanks

How to add swiping dots to Tabbed/Carousel page?

$
0
0

I'm wondering how to add dots indicating to swipe screens in either TabbedPage or CarouselPage like in the below image?

I tried adding images for that but they don't look natural so is there a real way for doing that?

My above workaround explanation in an example with 3 page:

I create 3 images each image has 3 dots one of them is highlighted:

First image highlighted dot is the first one.

Second image highlighted dot is the second one.

and etc.

Colorize one or several part(s) of a label's text

$
0
0

Hi,

I developed a page presenting some users. This last one is simply containing an entry and a listing.

I tried to colorize the users' informations matching with the text previously typed into the entry by using the Label property named FormattedText.

At first, the result was not so great and I discovered that using the FormattedText is actually displaying the informations in a very slowy way so I implemented a little hack that was simply splitting my string in X substrings and creating a label for each one of them that I would concat into an horizontal stacklayout.

The solution is working great on iOS, but on Android it's lagging a lot when I am scrolling down / up...

I am surprise to see that there is not control handling such basic behavior or maybe I missed them. Does anyone have an idea to implement a better solution ?

I thank you in advance and wish you a great weekend !
Best regards,

Xamarin UWP Map is blank

$
0
0

my maps on UWP is blank, just a black screen with the zoom buttons. i have given capabilities, put the init codes in the UWP app.xaml.cs.
HELP

Custom navigation bar with MasterDetailPage

$
0
0

At present my app uses normal ContentPages inside a NavigationPage which works fine. I have a ControlTemplate for customising the top navigation bar away from the default.
<ContentPage ControlTemplate="{StaticResource MainPageTemplate}"
It seems I am not able to do the same for MasterDetailPage as it appears I can't use a ControlTemplate?
<MasterDetailPage ControlTemplate="{StaticResource MasterDetailTemplate}"

Is there a way to customise the navigation bar for a MasterDetailPage?

Ref: this is the approach that I have used for having a custom navigation bar:
http://lukealderton.com/blog/posts/2017/january/replacing-the-xamarin-headernavigation-bar-with-a-custom-viewtemplate/``

Xamarin and ChromeCast

$
0
0

We would like to create an app in Xamarin for phones and tablets (both Android and iOS) that can use Google ChromeCast (like YouTube, Vimeo, Facebook, etc.). The app should be able to crhomecaste a movie from the app to eg a TV (via chromecast).

The libraries that is available do not seem to be up to date and work properly.

We would really appreciate to get in contact with a person/company who has succeeded in making chromecast in a Xamarin app that works properly and is active in the Apple App Store and Google Play Store.

Does anyone here have knowledge about an app built in Xamarin that uses Chromecast that works properly?

Entry control is firing Focused event on every cursor blink

$
0
0

Hi,

I found out that the Entry control's event "Focused" is being fired up every time the cursor blinks... So let's say you have simple code:
MyEntry.Focused += (object sender, FocusEventArgs e) =>{ someCode };
you start the app, you click in the entry, the cursor starts to blink -> every blink will fire up this code.

Do you guys think this is how the Focused should be used? I have reported this as a bug, any thoughts?

:)


How to get the length in seconds of a WAV file?

$
0
0

Hi guys, I have been trying to find out how to get the length of a wave file recording for both Android and iOS.
Can it be done in the PCL, or there are specific platform methods to get this length?

Need help debugging random crashes in GridCalc.cs

$
0
0

Hi, it's been a year or so that im getting random crashes in GridCalc, totally fail to repro, making it impossible for me to avoid. It's just random, on both iOS and Android, whatever forms version, being on latest atm.
Even worse, I cant seem to match Xamarin open source code i can find in inet with stacktrace lines numbers.
If anyone could could give me a direction to dig in, would be grateful for any clue:

12-12 16:08:53.456 I/MonoDroid( 7446): UNHANDLED EXCEPTION:
Thread started: <Thread Pool> #13
12-12 16:08:53.776 I/MonoDroid( 7446): System.NullReferenceException: Object reference not set to an instance of an object.
12-12 16:08:53.777 I/MonoDroid( 7446):   at Xamarin.Forms.Grid.MeasureStarredRows () [0x0017c] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:530 
12-12 16:08:53.777 I/MonoDroid( 7446):   at Xamarin.Forms.Grid.MeasureAndContractStarredRows (System.Double width, System.Double height, System.Double totalStarsHeight) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:403 
12-12 16:08:53.778 I/MonoDroid( 7446):   at Xamarin.Forms.Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) [0x00117] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:510 
12-12 16:08:53.778 I/MonoDroid( 7446):   at Xamarin.Forms.Grid.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0002a] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:58 
12-12 16:08:53.778 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.778 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x00236] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:198 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.779 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.780 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.780 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x00236] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:198 
12-12 16:08:53.783 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
12-12 16:08:53.783 I/MonoDroid( 7446):   at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.ScrollView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\ScrollView.cs:233 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.784 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0003c] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:39 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:760 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:642 
12-12 16:08:53.785 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 
12-12 16:08:53.786 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:700 
12-12 16:08:53.786 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x00110] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:165 
12-12 16:08:53.786 I/MonoDroid( 7446):   at Xamarin.Forms.AbsoluteLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00046] in D:\a\1\s\Xamarin.Forms.Core\AbsoluteLayout.cs:69 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x0014b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:263 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:223 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:798 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Xamarin.Forms.Layout+<>c.<OnChildMeasureInvalidated>b__45_0 () [0x00080] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:380 
12-12 16:08:53.787 I/MonoDroid( 7446):   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <ad2f15102b3a4d36b40e9b0cbc11c376>:0 
12-12 16:08:53.788 I/MonoDroid( 7446):   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <ad2f15102b3a4d36b40e9b0cbc11c376>:0 

CarouselView state of the union?

$
0
0

What is the status of the CarouselView component? Here is what I think I know:

  1. Microsoft created CarouselPage but has deprecated it since it is not flexible since it is a Page and can't be used in a ContentPage
  2. Microsoft created CarouselView within Xamarin.Forms repo but it was too buggy so they moved it to its own repo
  3. Microsoft's CarouselView repo has been stagnant for 2 years
  4. alexrainman made his own which Microsoft like better so the plan was to incorporate his into the official Xamarin.Forms repo as the official CarouselView control
  5. alexrainman's CarouselView repo has been stagnant for 7 months
  6. I do not see alexrainman's CarouselView merged into Xamarin.Forms repo
  7. I see several bugs within alexrainman's CarouselView and I have even submitted a pull request for one of them

What CarouselView component should I use? Should I try Telerik's RadSlideView or SyncFusion's SfCarousel instead??

Not sure what it is called in mobile apps... but how you alert a user after button click?

$
0
0

Hi All,

I am Not sure what it is called in mobile apps... but how you alert a user after button click? That the process has been completed.
I think I would like for the after click action to give the user a message that a process is complete and then take them back to the application
start page so they have a sense the something happened after they clicked the button.

So for example the user press the button save this record.

I would like a message to come up saying saving record...and then return to the application's welcome page.

Is this possible?

Can I send a value to my Webapi not to be stored in database but as a parameter to return data

$
0
0

Hi All,

So I am using web api to post data to a database on the server.. work great easy to understand how its working...
But in this case.. the users want to be able to send and Id via their devices and have that Id get processed and
return a value back to a list display on the device...

So and web api get.. but with a parameter... Is there some example I can follow showing how this can be done...
I am sure this is more a question for web api people

But I wanted to check here first.. because I was not sure how to refresh the page on the device if this can be done.

Thanks.

Viewing all 91519 articles
Browse latest View live


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