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

Activity Indicator two or more colors

$
0
0

Hey
I Programm in Visual Studio 2017 with Xamarin
I saw in an example, where their Activity Indicator had two Colors.
it looked as if there were two Activity Indicators one above another and with a litte time difference...
does anyone know how i can implement that?
because when i put two activity indicators at the same place i only can see one...
maybe because they start at the same time? (but i experimented a bit with wait etc so idk)
or maybe because ist not possible?
Thanks


Issues making a custom activity indicator.

$
0
0

Hi there,

I was wondering if someone could point me in the right direction. Our app has the need for our own activity indicator (bloody Windows phone and their dots...). So I quickly threw together this class:

` public class CustomLoader : Image
{
public bool IsRunning
{
get
{
return _isRunning;
}
set
{
_isRunning = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("IsRunning"));
}
}
}

    private bool _isRunning;
    private FileImageSource loader = new FileImageSource() { File = "LOADER.png" };
    private FileImageSource check = new FileImageSource() { File = "CHECK.png" };

    public CustomLoader(): base()
    {
        base.Source = new FileImageSource() { File = "LOADER.png" };
        this.PropertyChanged += IsRunningChanged;
        Task.Factory.StartNew(() =>
        {
            while(_isRunning)
            {
                this.Rotation += 0.02;
            }
        });
    }

    protected PropertyChangedEventHandler PropertyChanged;

    private void IsRunningChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {  
        if(((CustomLoader)sender).IsRunning == false)
        {
            base.Source = check;
        }
    }
}`

The class is then used like this:

`viewModel.SynchronisationManager.SynchronisationStateChanged += (object sender, SynchronisationStateChangedEventArgs e) => {
Controls.CustomLoader loader = new Controls.CustomLoader();
loader.IsRunning = true;

            var label = new Label();
            string key = String.Format("{0}_{1}", Prefix, e.SynchronisationState);
            label.Text = Strings.ResourceManager.GetString(key);
            label.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
            label.HorizontalOptions = LayoutOptions.Center;

            try
            {
                                Device.BeginInvokeOnMainThread(() =>
                             {                      
                                    list.Children.Add(new StackLayout()
                                    {
                                        VerticalOptions = LayoutOptions.Center,
                                        Orientation = StackOrientation.Horizontal,
                                        Children = 
                                        {
                                            loader,
                                            label
                                        }
                                    });
                             });
                    }
            catch (Exception eek)
            {
                Logging.LogException(eek);
            }
        };`

However, even though the the while loop continues to run inside the CustomerLoader, the UI doesn't respond to the image's change in rotational value. however, if the CustomLoader is declared outside of this event handler, the loader will spin as expected, the problem being that I need multiple loaders on my screen.

As an experiment I tried instantiating ActivityIndicators within the event handler and they continue to animate just fine.

I have an alternative which is to use a single loader and on the event firing, find the previous loader by reference and replace it with a different Image element, but I'd rather avoid this inelegant implementation (and I'd at least like to know the reason for my underyling issue!).

Cheers,
/Ant

Xamarin Opacity and IsVisible properties aren't working at run time after Forms package update.

$
0
0

I recently updated my Xamarin Forms packages on a new project I've been working on. After doing this, I noticed that my IsVisible and Opacity Data Bound UI elements no longer change based on button clicks etc. If I set the values in the constructor of my view controller, it sets it and displays accordingly. If I try to set it after that on a button or label click, within a command, the OnPropertyChanged event fires but the UI elements don't adjust.

This was working flawlessly prior to the update and I've not changed any Binding code. Is anyone else experiencing this?

Edit: After doing some more testing, I found this is also the case with setting any element in data binding. It works fine in the constructor but trying to set the values in a command triggers the OnPropertyChanged event but never actually adjusts the UI.

How to move the Flyout Menu to the right?

$
0
0

Hello all!
I can't find answer, how can i place menu in Xamarin.Forms.Shell at right side of the screen on Android?
Is there any way for it?
Thanks at advance!

Switching TabbedPage views depending on platform

$
0
0

I posted this on SO without any answers so thinking here might get an answer. Due to design differences in my app pages, I need to show one of the tab pages depending if its running on Android or iOS. I am trying to do like this below but it is not working, it seems to compile but the app crashes immediately. This is what I tried:

 <TabbedPage.Children>
        <OnPlatform x:TypeArguments="View">
            <On Platform="Android">
                <NavigationPage Title="{x:Static resources:AppResources.StatsTitle}" IconImageSource="stats1.png">
                    <x:Arguments>
                        <views:StatsPageAndroid />
                    </x:Arguments>
                </NavigationPage>
            </On>
            <On Platform="iOS">
                <NavigationPage Title="{x:Static resources:AppResources.StatsTitle}" IconImageSource="stats2.png">
                    <x:Arguments>
                        <views:StatsPageIos />
                    </x:Arguments>
                </NavigationPage>
            </On>
        </OnPlatform>

        . 
        .
        .
    </TabbedPage.Children>

What is the way to do this?

Thank you

Is there a good plugin for this for Xamarin.forms?

$
0
0

Unfortunately, I don't know what this type of control is called so I'm simply going to leave a picture of it here. I'm essentially wanting to open a page kind of like modal style from the bottom of the page and have it stay just shy of the top. Almost exactly like the picture below. Anyone know of a good nugget plugin for this?

Also what is this type of (window?) called?

Keep saying "There were deployment errors. Continue?"

$
0
0

Hi brothers. My problem is not that my project never works. It works but if i build it 5-6 times or so it starts to give this error. It sometimes fixes when i clean and rebuild solution, it always fixes when i restart vs2019 but this is getting tiresome. anybody having same problem?

WatchOS apps keep crashing when running on hardware

$
0
0

Hi,
have been running on Xamarin.iOS version 13.2 for quite some time and have a pretty basic Apple Watch app which was working very smoothly until I did an update to the latest Xamarin.iOS 13.14 version. Suddenly my watch app, and as a matter of fact all sample watch apps, keep crashing on start. In simulator everything's working as expected. Does anyone else experience something similar?
This is my configuration:
Visual Studio Enterprise 2019 for Mac
Version 8.5 (build 3183)
Mono Framework MDK
Runtime:
Mono 6.8.0.123 (2019-10/1d0d939dc30) (64-bit)
Package version: 608000123
Xamarin.iOS
Version: 13.14.1.39 (Visual Studio Enterprise)

Hardware
iPhone 11 Pro Max with iOS 13.4
Apple Watch S4 with WatchOS 6.1

This is the log I was able to pull out from the test watch app:

Thread 0 name: tid_407 Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x21450c70 __pthread_kill + 8
1 libsystem_pthread.dylib 0x214cd980 pthread_kill + 220
2 libsystem_c.dylib 0x213a46f4 abort + 100
3 ...CSessionAppWatchOSExtension 0x04ace56c print_callback(char const*, int) + 6137196 (runtime.m:1218)
4 ...CSessionAppWatchOSExtension 0x04ac56e8 monoeg_g_logv_nofree + 6100712 (goutput.c:150)
5 ...CSessionAppWatchOSExtension 0x04ac5738 monoeg_g_log + 6100792 (goutput.c:165)
6 ...CSessionAppWatchOSExtension 0x04ab7c4c mono_threads_transition_do_blocking + 6044748 (mono-threads-state-machine.c:725)
7 ...CSessionAppWatchOSExtension 0x04ab5648 mono_threads_enter_gc_safe_region_unbalanced_with_info + 6035016 (mono-threads-coop.c:324)
8 ...CSessionAppWatchOSExtension 0x04a20674 mono_gc_pthread_create + 5424756 (sgen-mono.c:2432)
9 ...CSessionAppWatchOSExtension 0x04ab6aa4 mono_thread_platform_create_thread + 6040228 (mono-threads-posix.c:101)
10 ...CSessionAppWatchOSExtension 0x04a43edc create_thread + 5570268 (threads.c:1384)
11 ...CSessionAppWatchOSExtension 0x04a4397c mono_thread_create_internal + 5568892 (threads.c:1474)
12 ...CSessionAppWatchOSExtension 0x0499a098 mono_gc_init_finalizer_thread + 4874392 (gc.c:1002)
13 ...CSessionAppWatchOSExtension 0x04ad55ac -[XamarinGCSupport init] + 6165932 (monotouch-main.m:199)
14 ...CSessionAppWatchOSExtension 0x04ad5984 xamarin_main + 6166916 (monotouch-main.m:462)
15 ...CSessionAppWatchOSExtension 0x044fc504 xamarin_watchextension_main + 34052 (main.m:47)
16 libdyld.dylib


The tap gesture recognizer not work in the span of a label?

$
0
0

please check the image.

the text underlined has a tapgetsture recognizer. but when I tap it it will not work.

only if I tap the white space around it then it will work.

and some of it is not work some of it works well.

why is it?

How to refresh the lanuchScreen?

$
0
0

I set the LaunchScreen.storyboard but the app not refreshed

need I do something else?

Image in listview is invisible even though its IsVisible is true.

$
0
0

I have this app in XF 4.4 that I've been developing for 2 years now. Lately I noticed some weird Image control behavior. I have a ListView of ViewCells containing Image control. The image's IsVisible property is bound to a property in ProcessAction class. When the user taps a row, the image becomes visible, when it taps it once more it goes hidden. I noticed that when I make some of images visible, close the page and then open it once more (all the time with the same ViewModel) the images are hidden even though their IsVisible properties are correctly set to true. So when I tap the ViewCell once more, apparently nothing happens, as then Image's IsVisible is set to false. So it behaves like Images were not properly restored from ViewModel when page loads. It might be related to GlideX as I lately added it to my project, though I think it worked this way before.

<ListView x:Name="lstActions" ItemsSource="{Binding Items}" ItemTapped="Handle_ItemTapped" VerticalOptions="FillAndExpand" HasUnevenRows="True" SeparatorVisibility="Default" CachingStrategy="RecycleElement"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout Padding="10"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="8*"/> <ColumnDefinition Width="2*"/> </Grid.ColumnDefinitions> <Image Source="tick_green.png" Grid.Row="0" Grid.Column="0" HeightRequest="50" IsVisible="{Binding IsChecked}" IsEnabled="{Binding IsMutable}"/> <Label Text="{Binding ActionName}" LineBreakMode="WordWrap" Style="{DynamicResource ListItemTextStyle}" FontSize="Medium" FontAttributes="Bold" IsEnabled="{Binding IsMutable}" Grid.Row="0" Grid.Column="1"/> <Image Source="exclamation_red.png" Grid.Row="0" Grid.Column="2" HeightRequest="50" IsVisible="{Binding IsRequired}"/> </Grid> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

Code behind:

`ActionListViewModel vm;

    public ActionList(ActionListViewModel _vm)
    {
        InitializeComponent();
        vm = _vm;
        BindingContext = vm;
    }

    async void Handle_ItemTapped(object sender, ItemTappedEventArgs e)
    {
        if (e.Item == null)
            return;
        if ((bool)((IActionKeeper)e.Item).IsMutable)
        {
            if ((bool)((IActionKeeper)e.Item).IsChecked)
            {
                ((IActionKeeper)e.Item).IsChecked = false;
                IActionKeeper item = ((IActionKeeper)e.Item);
                if (vm.CheckedItems.Any(i => i.ActionId == item.ActionId))
                {
                    vm.CheckedItems.Remove(vm.CheckedItems.FirstOrDefault(i => i.ActionId == item.ActionId));
                }
            }
            else
            {
                ((IActionKeeper)e.Item).IsChecked = true;
                IActionKeeper item = ((IActionKeeper)e.Item);
                if (!vm.CheckedItems.Any(i => i.ActionId == item.ActionId))
                {
                    vm.CheckedItems.Add(ToProcessAction(item));
                }

            }
        }
        else
        {
            DependencyService.Get<IToaster>().LongAlert($"Czynność została oznaczona jako wykonana w innej obsłudze i nie można jej zmienić..");
        }



        //Deselect Item
        ((ListView)sender).SelectedItem = null;
    }`

Items property in ActionListViewModel:

private ObservableCollection<IActionKeeper> _items { get; set; } public ObservableCollection<IActionKeeper> Items { get { return _items; } set { if (_items != value) { _items = value; OnPropertyChanged(); } } }

And ProcessAction class that works as a model for listview's cell:

public class ProcessAction : Entity<ProcessAction>, IActionKeeper, INotifyPropertyChanged
    {
        public int ProcessActionId { get; set; }
        public override int Id
        {
            set => value = ProcessActionId;
            get => ProcessActionId;
        }

        public Nullable<int> ProcessId { get; set; }
        public Nullable<DateTime> PlannedStart { get; set; }
        public Nullable<DateTime> PlannedFinish { get; set; }
        public string PlaceName { get; set; }
        public Nullable<int> ActionId { get; set; }
        public string ActionName { get; set; }
        public int? GivenTime { get; set; }
        public int? HandlingId { get; set; }
        public string Type { get; set; }
        public int? PlaceId { get; set; }
        public bool? _IsMutable { get; set; } = true;

        public bool? IsMutable
        {
            get
            {
                return _IsMutable;
            }
            set
            {
                if (value != _IsMutable)
                {
                    _IsMutable = value;
                    OnPropertyChanged();
                }
            }
        }

        public bool IsRequired
        {
            get
            {
                if (PlannedStart == null)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
        }

        public bool? _IsChecked { get; set; }
        public bool? IsChecked
        {
            get
            {
                if (_IsChecked == null)
                {
                    return false;
                }
                return _IsChecked;
            }
            set
            {
                if (value != _IsChecked)
                {
                    _IsChecked = value;
                    OnPropertyChanged();
                }
            }
        }

        public List<DateTime?> LastChecks { get; set; }
        public DateTime? LastCheck
        {
            get
            {
                if (LastChecks.Any())
                {
                    return LastChecks.FirstOrDefault();
                }
                else
                {
                    return null;
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged([CallerMemberName] string name = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }

Override Single Setter of StaticResource Style possible?

$
0
0

Hi,

in App.xaml I have defined a Style like this:
<Style TargetType="Label" x:Key="ControlLabel"> <Setter Property="FontAttributes" Value="Bold" /> <Setter Property="TextColor" Value="Blue" /> <Setter Property="Margin" Value="0,10,0,0" /> </Style>

Now I use this everywhere, but on one Special Label I want to remove the Margin, so I tried this:
<Label Text="Text" Style="{StaticResource ControlLabel}" Padding="0,0,30,0" Margin="0,0,0,0"/>

But the Margin is still 10. How can I override a specific Setter inline?

Thank you

How to fix "Waiting for Intellicense to finish initializing"

$
0
0

Hi there!
After update to Visual Studio 16.5.1 (Community Edition 2019), when I add a new page to project, a page is showed with the message: "Waiting for Intellicense to finish initializing...", but this process/task never ends.
I need to close the page and reopen it.
Is there a way to fix that?

Best regards!

xamarin forms: System.ArgumentNullException has been thrown (IOS)

$
0
0

I am using webview for parsing my HTML data. For this, I am using a custom render.

In the Main Project:

public  class MyWebView : WebView
{
    public static readonly BindableProperty UrlProperty = BindableProperty.Create(
    propertyName: "Url",
    returnType: typeof(string),
    declaringType: typeof(MyWebView),
    defaultValue: default(string));

    public string Url
    {
        get { return (string)GetValue(UrlProperty); }
        set { SetValue(UrlProperty, value); }
    }
}

Ios Renderer

public class MyWebViewRenderer : ViewRenderer<MyWebView, WKWebView>
{
    WKWebView _wkWebView;
    protected override void OnElementChanged(ElementChangedEventArgs<MyWebView> e)
    {
        base.OnElementChanged(e);

        if (Control == null)
        {
            var config = new WKWebViewConfiguration();
            _wkWebView = new WKWebView(Frame, config);
            SetNativeControl(_wkWebView);
        }
        if (e.NewElement != null)
        {
            Control.LoadHtmlString(Element.Url, null);   //use this code instead
            //Control.LoadRequest(new NSUrlRequest(new NSUrl(Element.Url)));
        }
    }
}

In XAML and XAML.cs:

<local:MyWebView 
    x:Name="web_view"
    VerticalOptions="FillAndExpand"/>

web_view.Url = htmldata;

But I am getting System.ArgumentNullException when running the project.

Screenshots:

enter image description here

I have uploaded a sample project here.

Listview is scrolling in iOS but not Android.

$
0
0

The Listview is only scrolling in iOS but not Android. can you please check what I am doing wrong?

<ContentView.Content>
        <AbsoluteLayout Margin="0,0,30,0">
            <Entry
                x:Name="searchBar"
                AbsoluteLayout.LayoutBounds="0,0,1,AutoSize"
                AbsoluteLayout.LayoutFlags="WidthProportional"
                BackgroundColor="White"
                HeightRequest="40"
                Placeholder="Enter sensor"
                TextChanged="SearchBar_OnTextChanged"
                TextColor="{DynamicResource RelogixDarkGray}"
                VerticalOptions="Center" />
            <ListView
                x:Name="dataListView"
                AbsoluteLayout.LayoutBounds="5,40,.98,.4"
                AbsoluteLayout.LayoutFlags="SizeProportional"
                BackgroundColor="White"
                CachingStrategy="RecycleElement"
                HasUnevenRows="True"
                IsVisible="False"
                ItemTapped="ListView_OnItemTapped">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>

                            <StackLayout Margin="5" Padding="0">
                                <Label
                                    BackgroundColor="White"
                                    FontFamily="{StaticResource NormalFont}"
                                    FontSize="16"
                                    Text="{Binding .}"
                                    TextColor="#FF464859"
                                    VerticalOptions="Center"
                                    VerticalTextAlignment="Center" />
                            </StackLayout>

                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </AbsoluteLayout>
    </ContentView.Content>

Binding in scrollView, i can use Property from ma view model

$
0
0

Hi, I Dont know why, by property from my view model doesnt work in my xaml

 private bool _isMonthsView;
        public bool IsMonthsView
        {
            get => _isMonthsView;
            set
            {
                _isMonthsView = value;
                RaisePropertyChanged(nameof(IsMonthsView));
            }
        }

<Label
                                                Grid.Row="2"
                                                HorizontalTextAlignment="Center"
                                                IsVisible="{Binding BindingContext.IsMonthsView}"
                                                Text="{Binding Day}"
                                                TextColor="White" />

Label is inside scrooview

how to print the input inside a string?

$
0
0

I am trying to print the input entered by the user inside an alert. Can you tell me what I am doing wrong.

void AddButton_Clicked(System.Object sender, System.EventArgs e)
{
if(!string.IsNullOrEmpty( SensorLookup.Text))
{
MessagingCenter.Send<AllocateSensorViewCell, int>(this, MessagingConstants.AllocateSensor, Convert.ToInt32(SensorLookup.Text));
}
else
{
Application.Current.MainPage.DisplayAlert("hello", "Please check the " + SensorLookup.Text + ".", "ok");
}
}


SSO Authenticate to Microsoft.Graph and an Azure App Service

$
0
0

Hi,

I want to be able to access microsoft.graph and and azure app service from xamarin forms. I can follow tutorials on how to do each one individually, but lost how to do SSO with both.

Authenticate to an azure app service: docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-users

Authenticate to Microsoft Graph: docs.microsoft.com/en-us/graph/tutorials/xamarin

I know graph has the ability to expose an api which is what I may be looking for: docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-expose-web-apis

If anyone is able to provide code samples, walk me through, or help me fill in gaps with what I am trying to do I will be very grateful.

Thanks for your time.

Scroll bar visibility

$
0
0

Is there a way to detect if the scrollbar of the scroll view is visible or if its already scrollable?

CrossFirebasePushNotification.Current.OnTokenRefresh not responding after changing the package name

$
0
0

Using FirebasePushNotification plugin .
Push notification feature was running perfectly.
I just changed the package name in manifest.
(Created new firebase project and Changed the google-services.json file also)
new token is not getting generated while running the application.
OnTokenRefresh is not responding.

I have checked it with Android devices(Lenovo and redmi 5 pro).

Birdie.Plugin.FirebasePushnotification version- 2.3.8
Plugin.FirebasePushnotification version-3.1.6

Thanks in advanz.

Viewing all 91519 articles
Browse latest View live


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