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

How to programmatically set the placeholder color for a disabled Entry on UWP?

$
0
0

Can anybody tell me please how to specify the color of the placeholder for an Entry that is disabled on UWP?

I know I can workaround it by placing another View over the top of the Entry, but it would be useful to do it "properly" in a custom Entry renderer.


How to get Local time for a specific zone using .NET Standard?

$
0
0

Hi,

I am using this in C# but I want to get the same in Xamarin in order to get the current time for Dubai.

How to achieve that?

I tried the same code but getting:

System.TimeZoneNotFoundException: Arabian Standard Time
at System.TimeZoneInfo.GetMonoTouchData (System.String name, System.Boolean throw_on_error) [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/corlib/System/TimeZoneInfo.MonoTouch.cs:98
at System.TimeZoneInfo.FindSystemTimeZoneByIdCore (System.String id) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/corlib/System/TimeZoneInfo.MonoTouch.cs:56
at System.TimeZoneInfo.FindSystemTimeZoneById (System.String id) [0x00021] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/corlib/System/TimeZoneInfo.cs:574
at Jafaria.HomePage.GetDubaiLocalTime () [0x00001] in /Users/jassim/Projects/Jafaria/Jafaria/HomePage.xaml.cs:274
at Jafaria.HomePage+d__15.MoveNext () [0x0001e] in /Users/jassim/Projects/Jafaria/Jafaria/HomePage.xaml.cs:306
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at UIKit.UIKitSynchronizationContext+<>c__DisplayClass1_0.b__0 () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIKitSynchronizationContext.cs:24
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/Foundation/NSAction.cs:125
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at Jafaria.iOS.Application.Main (System.String[] args) [0x00001] in /Users/jassim/Projects/Jafaria/iOS/Main.cs:18

here is the code:

TimeZoneInfo DubaiTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Arabian Standard Time");
DateTime utc = DateTime.UtcNow;
DateTime DubaiLocalTime = TimeZoneInfo.ConvertTimeFromUtc(utc, DubaiTimeZone);

// DateTimeOffset DubaiLocalTime = TimeZoneInfo.ConvertTime(DateTimeOffset.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Arabian Standard Time"));

LabelHomeMageLocalTime.Text = DubaiLocalTime.ToString("HH:mm");

Thanks,
Jassim

How do I validate a number in my app?

$
0
0

Hi guys,

in my project I have simple number input where users can type their number in. How can I check if their number is correct? Do you guys know an API for this, maybe for sending or something? Has any of you implement such a feature?

Please let me know.

Disable device back button

$
0
0

Hi all.

Any one know how to disable device back button in xamarin forms app?

Thanks
Lasantha

Is possible to avoid slow startup time of xf app on Android in this way?

$
0
0

I made a big xamarin form app for ios and android, all is working great, but on Android app take till 8 seconds to starts.
I already try to use XAML Compilation and AOT...the AOT gain 2seconds, but it double the size of my apk, so is not a solution for my needs.

My question:
If I try to:
- rewrote only the first page in xamarin android
- start the app in native way
- while first view is shown, init the xamarin form engine (using callback, timers or in other async way) and after the init use only xf page
the startup time for my xamarin android app should be better?

Thanks for answer
Matteo

how to disable or remove copy and back icon from the Xamarin forms picker

$
0
0

I have a picker with 3 options , when it slides up, it comes with previous , next and copy icon, when clicked on copy icon, previous and next button gets activated and on click of those, app crashes

how to solve dis???
please give inputs

thanks in advance

How to update the UI label value from backend page without refreshing the page?

$
0
0

Hey,
I am working on a project where in xaml page it has a label and by binding the property associate value is showing.
There is an entry field that accepts the value and send to server and in the label value that data is being fetched and showing.
I want that old label value always be updated when the property value is updated at back end or in server without refreshing the whole page.
Help me.

Connect to sql Server

$
0
0

I need connect to sql server resident on local server

Can anyone help me?

Thanks

i use:
string connectionString = @Server=192.168.1.22;Database=DB_DATI_UBIK_STORE_PRO;User Id=sa;Password=bladerunner;Trusted_Connection=true;

but i recive this error:

exception = {System.Data.SqlClient.SqlException (0x80131904): Specified method is not supported.
at Interop+NetSecurityNative.ImportPrincipalName (Interop+NetSecurityNative+Status& minorStatus, System.String inputName, System.Int32 inputNameByteCount, Microsoft.Win32...

THANKS


How to restrict numeric values entered into an Entry field.

$
0
0

I need to restrict the value being typed into an Entry field to values between 0 and 20. However, I don't want highlight it in red if it's outside that range or anything, I want to actually prevent the value from appearing in the field if the user types 30, for example (the 3 would appear since it's valid but if the user then types a 0 it should not be accepted). I have successfully used behaviors to validate things like email addresses and date formats and was wondering if I can create a behavior to do this numeric validation and if so how I would go about it? Should I interrogate the entry using the TextChanged event or something?

How to force a refresh of a page?

$
0
0

I have a page with a 'button' (actually a TapGestureRecognizer on a StackLayout). When pressed I add or remove some things from another StackLayout in the page.

The problem is that on Android after pressing sometimes you still see parts of the previous screen like duplicate buttons (1 in old location and 1 in new location). This goes away when you touch the screen and scroll it a little bit. But I want to do this refresh from code.

What I tried:

  • ForceLayout() or InvalidateMeasure() on the page after my changes
  • ForceLayout() on the ScrollView after my changes
  • Putting the layout changes in a Device.BeginInvokeOnMainThread

I 'solved' it by scrolling from code after my changes: await scrollview.ScrollToAsync(scrollview.ScrollX, scrollview.ScrollY - 1, false);

Does anyone have a better solution? Or is it a bug in Forms that its makers should solve?

How to programmatically set the placeholder color for a disabled Entry on UWP?

$
0
0

Can anybody tell me please how to specify the color of the placeholder for an Entry that is disabled on UWP?

I know I can workaround it by placing another View over the top of the Entry, but it would be useful to do it "properly" in a custom Entry renderer.

How to get Local time for a specific zone using .NET Standard?

$
0
0

Hi,

I am using this in C# but I want to get the same in Xamarin in order to get the current time for Dubai.

How to achieve that?

I tried the same code but getting:

System.TimeZoneNotFoundException: Arabian Standard Time
at System.TimeZoneInfo.GetMonoTouchData (System.String name, System.Boolean throw_on_error) [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/corlib/System/TimeZoneInfo.MonoTouch.cs:98
at System.TimeZoneInfo.FindSystemTimeZoneByIdCore (System.String id) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/corlib/System/TimeZoneInfo.MonoTouch.cs:56
at System.TimeZoneInfo.FindSystemTimeZoneById (System.String id) [0x00021] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/corlib/System/TimeZoneInfo.cs:574
at Jafaria.HomePage.GetDubaiLocalTime () [0x00001] in /Users/jassim/Projects/Jafaria/Jafaria/HomePage.xaml.cs:274
at Jafaria.HomePage+d__15.MoveNext () [0x0001e] in /Users/jassim/Projects/Jafaria/Jafaria/HomePage.xaml.cs:306
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at UIKit.UIKitSynchronizationContext+<>c__DisplayClass1_0.b__0 () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIKitSynchronizationContext.cs:24
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/Foundation/NSAction.cs:125
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at Jafaria.iOS.Application.Main (System.String[] args) [0x00001] in /Users/jassim/Projects/Jafaria/iOS/Main.cs:18

here is the code:

TimeZoneInfo DubaiTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Arabian Standard Time");
DateTime utc = DateTime.UtcNow;
DateTime DubaiLocalTime = TimeZoneInfo.ConvertTimeFromUtc(utc, DubaiTimeZone);

// DateTimeOffset DubaiLocalTime = TimeZoneInfo.ConvertTime(DateTimeOffset.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Arabian Standard Time"));

LabelHomeMageLocalTime.Text = DubaiLocalTime.ToString("HH:mm");

Thanks,
Jassim

How do I validate a number in my app?

$
0
0

Hi guys,

in my project I have simple number input where users can type their number in. How can I check if their number is correct? Do you guys know an API for this, maybe for sending or something? Has any of you implement such a feature?

Please let me know.

ListView.Behaviors and Prism DelegateCommand problems

$
0
0

After hours of searching and trying I couldn't get the following to work.

Expected behavior: Tap on a item in a list once, navigate to a page. Tap 2-3 times (or more) on the same item quickly, still open ONE page and not more.

I have managed to do this, but when using a generic DelegateCommand it just won't work for some reason. I'm using Xamarin.Forms (version 3.1.0.637273) and Prism (version 7.1.0.172-pre).

In my XAML I have a ListView with the following behavior and bindings:

    <ListView 
         CachingStrategy="RecycleElement"
         ItemsSource="{Binding MyCollection}">
         <ListView.Behaviors>
              <b:EventToCommandBehavior
                   Command="{Binding MyCommand}"
                   EventName="ItemTapped"
                   EventArgsParameterPath="Item" />
         </ListView.Behaviors>
             <ListView.ItemTemplate>
                  <DataTemplate>
                       <ViewCell>
                           ...
                       </ViewCell>
                  </DataTemplate>
             </ListView.ItemTemplate>
    </ListView>

In my ViewModel I have:

    private ObservableCollection<SomeModel> _myCollection;
    public ObservableCollection<SomeModel> MyCollection
    {
        get { return _myCollection; }
        set { SetProperty(ref _myCollection, value); }
    }

    private bool _canNavigate;
    public bool CanNavigate
    {
         get { return _canNavigate; }
         set { SetProperty(ref _canNavigate, value); }
    }


    private DelegateCommand<SomeModel> _myCommand;
    public DelegateCommand<SomeModel> MyCommand =>
                _someModel ?? (_myCommand = new DelegateCommand<SomeModel>(ExecuteMethod, (parameter) => CanNavigate))
                .ObservesProperty(() => CanNavigate);

    private async void ExecuteMethod(SomeModel parameter)
    {
         CanNavigate = false;

         NavigationParameters parameters = new NavigationParameters($"?id={parameter.Id}");
         await NavigationService.NavigateAsync("SomeCoolPage", parameters);

         CanNavigate = true;
    }

I have also tried other varients with like this for example with no luck:

    private async void ExecuteMethod(SomeModel parameter)
    {
         if(CanNavigate)
         {
              CanNavigate = false;
              ...
              ...
              CanNavigate = true;
         }
    }

This code works when I'm not using the generic version of the DelegateCommand.

If anyone can point me to what is it I'm doing wrong that would be awesome. Thanks.

'Resource.Style' does not contain a definition for 'Main.Theme'

$
0
0

Getting this error while trying to use xamarin live player. Any ideas how to solve it?


How do I assign list of values to property in xaml?

$
0
0

I've made a custom control that has a property of list type:

MyMenu.cs

[ContentProperty("MyMenuItems")]
public class MyMenu : View
{
    public List<MyMenuItem> MyMenuItems { get; set; }
}

And I want to assign list of values to the property like this:

MyPage.xaml

<local:MyMenu>
    <local:MyMenuItem />
    <local:MyMenuItem />
</local:MyMenu>

But it doesn't work neither with <x:Array> extension.
How can I pass to the property in xaml?

Spam

PopToRootAsync is not supported globally on Android, please use a NavigationPage.

$
0
0

Hi,

Does anyone have any additional information regarding how I might work around the "PopToRootAsync is not supported globally on Android, please use a NavigationPage." error?

The same code works successfully on Windows Phone.

Thank you very much for your help.

Paul Diston

Can I set multiple styles to an element?

$
0
0

I tried with comma:

<ContentPage.Resources>
    <ResourceDictionary>
        <Style x:Key="large" TargetType="Label">
            <Setter Property="FontSize" Value="Large" />
        </Style>
        <Style x:Key="red" TargetType="Label">
            <Setter Property="TextColor" Value="Red" />
        </Style>
    </ResourceDictionary>
</ContentPage.Resources>

<StackLayout>
    <Label Style="{StaticResource large, red}" Text="large red text" />
</StackLayout>

But only the red style was applied.
It seems like later one override the others.
Can I use two or more styles simultaneously?

Xamarin.Forms.Maps android error!!

$
0
0

Hola!!! I'm starting with Xamarin maps, using Microsoft documents to guide me, in IOS the map loads well, but in Android I get an error
Java.Lang.IllegalStateException has been thrown (line 19-... " base.OnCreate(bundle); "..message= "You need to use a Theme.AppCompat theme (or descendant) with this activity."
{md5fc2263bf39d4ddd0f7a1b1385473b882.MainActivity@e673525}

Viewing all 77050 articles
Browse latest View live


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