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

Swipe gesture on a view which is a child of a TabbedPage

$
0
0

Hi,

On Android, I'm implementing a trackpad that anable the user to do gesture. This track pad is a BoxView on which I added gesture tracking (IOS/Android) and is a child of a tabbedpage. All gesture are ok on Android except Swipe left and right since they are "captured" by the Tabbedpage to allow the user to change tabbedpage section.
So my question is, is there a way to prevent the TabbedPage control to "capture" this swipe gesture ?
Or anyway to disable the swipe at all on the TabbedPage.

Finaly, I wanted to override te renderer of a TabbedPage on Android but apparently the "TabbedRederer" is not the good one since without adding any code, and using this renderer the TabbedPage doesn't look as a tabbed Page anymore (Only one children is shown)

Romain


Does Xamarin.Forms support Handoff in iOS?

$
0
0

Hi,

I was wondering if Xamarin.Forms can support this feature. By reading the docs, I assume that maybe it can be used somehow but, is it possible at all?

DatePicker in Lollipop is a pain

$
0
0

I don't know if that is due to Lollipop or Xamarin.Forms. If you have to set to 1950's then you have to scroll a lot. This is a pain if you are testing on Mac with an emulator as this control is very good for 'touch' and Mac's don't have 'touch'.

Asking for a friend...feeling the same pain...

Using Rx together with Forms

$
0
0

Hi,

today I learned a lot about Reactive Extentions and also had a look at ReactiveUI framework for form. The later one did not convince me, as you have to do all the Binding again in Code.

I wonder how the typical pattern of publishing a Command in a ViewModel and Binding in Xaml to it can be extended, to almost bind to a Oberservable from Xaml.

What are your experiences using Rx together with Forms. How do you use it?

Cheers
Thomas

Unexpected HttpClient header behavior

$
0
0

Good evening,
I'm woking on a Xamarin.Forms project.
I have a PCL library in which I included my API.
The backend is configured to evaluate the User Agent using a special custom pattern. The custom User Agent string is built after the application launch, added to the httpClient used to make the further call using the method:
_httpClient.DefaultRequestHeaders.TryAddWithoutValidation ("User-Agent", custom_user_agent_string);
I had to use the TryAddWithoutValidation because of the format of the custom_user_agent_string string, any other method raises an exception or doesn't add the user agent header.
If I run the application from the iOS project all goes smoothly and the backend correctly reads the User Agent and response back.

I created a NUnit test project to test all my API, but running the same code from the NUnit library produce a different behavior.
I haven't written the backend nor I have access to the code but from the response I get I was able to guess it was because the user agent has not been set correctly ( I've already had the same server response when I was creating the user agent string in a bad way).
I debugged the app and looked at the user agent field in my http request and I found out that they actually are different.

While launching the app from the iOS project and adding the header isn't setting the UserAgent header field in the HttpClient.Headers, launching the app from the test project and adding the headers cause the client to correctly set the HttpClient.Headers.UserAgent property.

Obviously I'm using the same code.

While the second case seems the correct one, the server is responding me as I'm not setting the user agent in my request.

Any idea?

you MUST call Xamarin.Forms.Forms.Init() in DependencyService Sqlconnection

$
0
0

Guys,
I'm using geolocator to get users current location. When location is updated I have to access the database. The app works fine and call sqlconnection through DependencyService fine. But after about 3 minutes the app crash getting the sqlconnection by DependencyService in the same part that was working correctly.

This is the error i got at Android Device Logging:
image

I just don't understand why this is happening. I've added a Debug.WriteLine() to verify if the Dependency is beeing called other times and just work fine. I can't find a reason why Xamarin.Forms.Forms.Init() has to be called again after some time.

Code MainActivity Android:

[Activity(Label = "tbmobile", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        global::Xamarin.Forms.Forms.Init(this, bundle);
        LoadApplication(new App());
    }
}

And this is the Constructor of Database:

public TBDatabase()
{
    _connection = DependencyService.Get<ISQLite>().GetConnection();
}

Formatted Label with Xamarin.Forms

$
0
0

Can someone please show me how to use Xamarin.Forms.Label.FormattedText correctly?

I'm using Xamarin.Forms to write a Carousel based app, when I try

Label IntroductionTextLabel = new Label();
IntroductionTextLabel.FormattedText = "Test";

I get this error:

"'Xamarin.Forms.Label' does not contain a definition for 'FormattedText' and no extension method 'FormattedText' accepting a first argument of type 'Xamarin.Forms.Label' could be found (are you missing a using directive or an assembly reference?)"

Perhaps it's the version of Xamarin I'm currently using...

The next step would be using this to display some HTML.

Thanks for any help.

Prism: View using different viewmodels

$
0
0

We are using Prism.Forms for navigation and Prism.Unity for IOC in our app. Our App.xaml is a unity:PrismApplication.
The App.xamls.cs register types for navigation like this:
this.Container.RegisterTypeForNavigation<SomePage>();

Navigation is done like this:
this.NavigationService.Navigate(SomePage, SomeParameters);

All our viewmodels accept parameters and views are autowired to viewmodels in the xaml.

We have two viewmodels, PageAViewModel and PageBViewModel, where the latter is a subclass of the former. These two viewmodels are currently autowired to two pages, PageA and PageB. These XAML code for these two pages is almost identical - thus we would like to have a single page which can be wired to the two different viewmodels depending on the state of the app.

What is the recommended way of doing this? Can a parameter been passed to the view's constructor indicating which viewmodel to use?
How would that work given the underlying dependency injection mechanism and the navigation framework?


Styling ViewCell.ContextActions MenuItem

$
0
0

Is it possible to style a context action menuitem beyond the isDestructive property? If not could anyone point me towards the right direction, any resources etc. which describe a way to implement something like that?

Need to put HTML into a Label

$
0
0

I am using Xamarin.Forms and the Label view. I use the FormattedText (FormattedString class) to put formatted text in the Label. My goal here is to be able to convert HTML to a FormattedString.

In Xamarin.Android I have acces to Html.FromHtml() wich returns a ISpanned. Is there a equivalent for Xamarin.Forms ?

I cannot really use a WebView since my goal is to have multiple labels populated from HTML. If I use a WebView, I would be forced to do the whole page in HTML and not use Xamarin.Forms views/controls.

Thanks,
Max.

How to send Message from Background Thread to UI Thread?

$
0
0

Hi,

I have a Background Thread that does some sync work for me. Now I wonder if an Exception happens in the Background thread how can I communicate this to the GUI?

Thanks
Thomas

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

How do you tell if Forms.Init() has been called?

$
0
0

I'm working in the GCM service and I want to check it Form's is init'd before I call my container resolver. Is there a way to detect if Forms.Init() has happened? Is there a smarter way to do this?

Cannot update Entry.Text from attached Behaviour

$
0
0

I'm trying to implement some numeric entry field validation and after searching around it seems that using Behaviors is the way to go. The problem I have is that any changes the Behavior class makes to the Entry control are not applied.

Behaviour class...

public class QtyValidatorBehavior : Behavior<Entry>
{
    protected override void OnAttachedTo(Entry entry)
    {
        entry.TextChanged += OnEntryTextChanged;
        base.OnAttachedTo(entry);
    }

    protected override void OnDetachingFrom(Entry entry)
    {
        entry.TextChanged -= OnEntryTextChanged;
        base.OnDetachingFrom(entry);
    }

    void OnEntryTextChanged(object sender, TextChangedEventArgs args)
    {
        double result;
        bool isValid = double.TryParse(args.NewTextValue, out result);

        if (!isValid)
            ((Entry)sender).Text = args.OldTextValue;
    }
}

Usage...

      <Entry Text="" Keyboard="Numeric">
        <Entry.Behaviors>
            <local:QtyValidatorBehavior/>
          </Entry.Behaviors>
      </Entry>

Sticking a break point in the OnEntryTextChanged event and entering an invalid key shows that it is called twice, once for the captured text changed event with the entered text and then a second time when it sets it back to the OldTextValue because it is invalid. On this second time thru, the entry is valid since it now contains the correct value BUT the onscreen text has not changed.

I've tried doing something like changing the Entry.TextColor instead but to no avail.

I've also tried using a custom Entry control with an OnTextChanged event handler and just attaching an OnTextChanged event handler in the code behind neither of which worked either.

Tips or advice greatly appreciated.

Chris

mmap out of Memory, Videoview: “Can't play this video”

$
0
0

I have a large project where I'm storing videos in the raw file (Around a few gig) Everything has been going smoothly until now. Sometimes my videos will not play and show "Can't play this video" message, I've noticed I have been getting mmap failed: Out of memory errors in my stack trace and I'm struggling to resolve this issue, and my uri returns null.

Since my source code files are huge I'll be leaving out what I thought of as trivial code:

    VideoView Video = FindViewById <VideoView>(Resource.Id.videoViewMainActivty);


    MediaController mediaController = new MediaController(this, true);
    Video.SetMediaController (mediaController);

    var uri = Android.Net.Uri.Parse ("android.resource://" + PackageName + "/" + Resource.Raw.V11_2_1_1_Completing_the_square);
    Video.SetVideoURI (uri);
    Video.Start ();

Log:

[libEGL] loaded /system/lib/egl/libEGL_mali.so
[libEGL] loaded /system/lib/egl/libGLESv1_CM_mali.so
[libEGL] loaded /system/lib/egl/libGLESv2_mali.so
[] Device driver API match
[] Device driver API version: 10
[] User space API version: 10 
[] mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012 
[OpenGLRenderer] Enabling debug mode 0
Thread finished: <Thread Pool> #5
[Mono] [0xb8c7e958] worker finishing
Thread finished: <Thread Pool> #3
Thread finished: <Thread Pool> #4
[Mono] [0xb9648f00] worker finishing
[GestureDetector] [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 5 mFalseSizeCnt:0
[dalvikvm-heap] Grow heap (frag case) to 13.961MB for 1536016-byte allocation
[dalvikvm-heap] Grow heap (frag case) to 16.558MB for 2724712-byte allocation
[dalvikvm-heap] Grow heap (frag case) to 19.158MB for 2724712-byte allocation
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
Thread started: <Thread Pool> #6
Thread started: <Thread Pool> #7
[Mono] [0xb945f918] worker starting
Thread started: <Thread Pool> #8
[Mono] [0xba4f20e0] worker starting
Thread finished: <Thread Pool> #7
[Mono] [0xb945f918] worker finishing
[GestureDetector] [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 4 mFalseSizeCnt:0
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[GestureDetector] [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 5 mFalseSizeCnt:0
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[GestureDetector] [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 7 mFalseSizeCnt:0
[webclipboard] clipservice: android.sec.clipboard.ClipboardExManager@42367570
[webkit] BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {423615d0}
[webview] registerForStylusPenEvent onAttachedToWindow
[webview] registerForStylusPenEvent START
[webview] registerForStylusPenEvent END
Thread started: <Thread Pool> #9
[Mono] [0xbcd08d90] worker starting
[MediaPlayer-JNI] native_setup
[MediaPlayer] constructor
[MediaPlayer] setListener
[MediaPlayer] path is null
[filemap] mmap(0,1068406440) failed: Out of memory
[asset] create map from entry failed
[MediaPlayer] Couldn't open file on client side, trying server side
[MediaPlayer] setVideoSurfaceTexture
[MediaPlayer-JNI] setAudioStreamType: 3
[MediaPlayer] MediaPlayer::setAudioStreamType
[MediaPlayer] setVideoSurfaceTexture
[MediaPlayer] prepareAsync
[MediaPlayer] message received msg=100, ext1=1, ext2=-2147483648
[MediaPlayer] error (1, -2147483648)
Thread started: <Thread Pool> #10
[MediaPlayer] callback application
[MediaPlayer] back from callback
[Mono] [0xbd0a4958] worker starting
[ProgressBar] setProgressDrawable mProgressDrawable = null, d = android.graphics.drawable.LayerDrawable@42bf8ae0needUpdate = false
[ProgressBar] setProgress = 0
[ProgressBar] setProgress = 0, fromUser = false
[ProgressBar] mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
Thread started: <Thread Pool> #11
[Mono] [0xbd0ff870] worker starting
[MediaPlayer] Error (1,-2147483648)
[VideoView] Error: 1,-2147483648
[Mono] DllImport attempting to load: '__Internal'.
[Mono] DllImport attempting to load: '__Internal'.
[Mono] DllImport loaded library '(null)'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'monodroid_get_system_property'.
[Mono] Probing 'monodroid_get_system_property'.
[Mono] Found as 'monodroid_get_system_property'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'monodroid_free'.
[Mono] Probing 'monodroid_free'.
[Mono] Found as 'monodroid_free'.
[Mono] DllImport loaded library '(null)'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'monodroid_get_system_property'.
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

I've made sure my encoding is correct and the video does play sometimes. For some reason I'm having trouble with this video specifically. The file is 21MB, Could this be a problem? Might compressing all my videos and making sure the width and height are correct help solve this issue? or is there a way to "release" mmap memory? Any help would be much appreciated.


Customize picker popup on XF?

$
0
0

Is there any way to either decrease the font size or increase the window size of the picker's popup window?

I have some long text that's cutoff when making a selection.

Please, help me!!! My image can't be stratched on the size of the button!!!

$
0
0

<Button HeightRequest="150" Clicked="openCategories">
          <Button.Image >
            <OnPlatform x:TypeArguments="FileImageSource"
                        WinPhone="Assets/ico-categories@2x.png" />
          </Button.Image>
        </Button>

Please, help me!!! My image can't be stratched on the size of the button!!!

$
0
0

<Button HeightRequest="150" Clicked="openCategories">
          <Button.Image >
            <OnPlatform x:TypeArguments="FileImageSource"
                        WinPhone="Assets/ico-categories@2x.png" />
          </Button.Image>
        </Button>

ToolbarItem added to a TabbedPage is not displayed in XF.UWP project

$
0
0

For a ContentPage it is shown, but not in a TabbedPage. How do I show it? Do I have to add it to each of the ContentPage in each of the tabs?

Not able to open Windows Phone app in device

$
0
0

i have created a cross platform project and the app was successfully deployed and working fine in both Android and iOS device. But for windowsPhone after the installation of .appx file, when i tried to open the app in device, my app's getting opened and closed at the instance itself. But in windows phone emulator it working fine.

Also no error message or indication like ("Your App has crashed"). any idea or suggestion why i am getting like this?

Viewing all 81910 articles
Browse latest View live


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